eventstore: skip replacing when it's the exact same id.

This commit is contained in:
fiatjaf
2025-11-30 22:11:49 -03:00
parent a355f27adb
commit fb3b14c69c
3 changed files with 27 additions and 0 deletions

View File

@@ -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)