Skip to content

Commit

Permalink
fail on NextSequence() error instead of continuing with nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Aug 23, 2024
1 parent 3fba60b commit 6cc101b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions bolt/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ func (b *BoltBackend) DeleteEvent(ctx context.Context, evt *nostr.Event) error {
return nil
}

// seqb is the key where this event is stored at bucketRaw
seqb := key[8:]
if seqb == nil {
return nil
}

// calculate all index keys we have for this event and delete them
for _, k := range getIndexKeysForEvent(evt) {
Expand Down
6 changes: 5 additions & 1 deletion bolt/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ func (b *BoltBackend) SaveEvent(ctx context.Context, evt *nostr.Event) error {

// raw event store
raw := txn.Bucket(bucketRaw)
seq, _ := raw.NextSequence()
seq, err := raw.NextSequence()
if err != nil {
return fmt.Errorf("failed to get sequence when saving: %w", err)
}

seqb := binary.BigEndian.AppendUint32(nil, uint32(seq))
if err := raw.Put(seqb, bin); err != nil {
return err
Expand Down

0 comments on commit 6cc101b

Please sign in to comment.