eventstore: skip replacing when it's the exact same id.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"fiatjaf.com/nostr"
|
||||
"fiatjaf.com/nostr/eventstore/internal"
|
||||
"github.com/PowerDNS/lmdb-go/lmdb"
|
||||
)
|
||||
|
||||
func (il *IndexingLayer) ReplaceEvent(evt nostr.Event) error {
|
||||
@@ -47,6 +48,15 @@ func (il *IndexingLayer) ReplaceEvent(evt nostr.Event) error {
|
||||
}()
|
||||
iltxn.RawRead = true
|
||||
|
||||
// check if we already have this id
|
||||
_, existsErr := mmmtxn.Get(il.mmmm.indexId, evt.ID[0:8])
|
||||
if existsErr == nil {
|
||||
return nil
|
||||
}
|
||||
if !lmdb.IsNotFound(existsErr) {
|
||||
return fmt.Errorf("error checking existence: %w", existsErr)
|
||||
}
|
||||
|
||||
// now we fetch the past events, whatever they are, delete them and then save the new
|
||||
var results iter.Seq[nostr.Event] = func(yield func(nostr.Event) bool) {
|
||||
err = il.query(iltxn, filter, 10 /* in theory limit could be just 1 and this should work */, yield)
|
||||
|
||||
Reference in New Issue
Block a user