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

@@ -11,6 +11,15 @@ import (
func (b *LMDBBackend) ReplaceEvent(evt nostr.Event) error {
return b.lmdbEnv.Update(func(txn *lmdb.Txn) error {
// check if we already have this id
_, existsErr := txn.Get(b.indexId, evt.ID[0:8])
if existsErr == nil {
return nil
}
if operr, ok := existsErr.(*lmdb.OpError); !ok || operr.Errno != lmdb.NotFound {
return existsErr
}
filter := nostr.Filter{Kinds: []nostr.Kind{evt.Kind}, Authors: []nostr.PubKey{evt.PubKey}}
if evt.Kind.IsAddressable() {
// when addressable, add the "d" tag to the filter