eventstore: fix lmdb storing the same event a million times.

This commit is contained in:
fiatjaf
2025-08-22 17:58:32 -03:00
parent f0c95d6860
commit b88edca786
2 changed files with 4 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ func (b *BoltBackend) SaveEvent(evt nostr.Event) error {
// check if we already have this id
bin := rawBucket.Get(evt.ID[16:24])
if bin != nil {
// we should get nil, otherwise end here
// we should get nil, otherwise we already have it so end here
return eventstore.ErrDupEvent
}

View File

@@ -4,7 +4,6 @@ import (
"fmt"
"fiatjaf.com/nostr"
"fiatjaf.com/nostr/eventstore"
"fiatjaf.com/nostr/eventstore/codec/betterbinary"
"github.com/PowerDNS/lmdb-go/lmdb"
)
@@ -28,12 +27,12 @@ func (b *LMDBBackend) SaveEvent(evt nostr.Event) error {
// check if we already have this id
_, err := txn.Get(b.indexId, evt.ID[0:8])
if operr, ok := err.(*lmdb.OpError); ok && operr.Errno != lmdb.NotFound {
if operr, ok := err.(*lmdb.OpError); ok && operr.Errno == lmdb.NotFound {
// we will only proceed if we get a NotFound
return eventstore.ErrDupEvent
return b.save(txn, evt)
}
return b.save(txn, evt)
return err
})
}