Skip to content

Commit

Permalink
client/db/bolt: ignore notes with bad IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Feb 17, 2023
1 parent 09817d1 commit e48e3cd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion client/db/bolt/db.go
Expand Up @@ -1835,7 +1835,7 @@ func (db *BoltDB) AckNotification(id []byte) error {
// NotificationsN reads out the N most recent notifications.
func (db *BoltDB) NotificationsN(n int) ([]*dexdb.Notification, error) {
notes := make([]*dexdb.Notification, 0, n)
return notes, db.notesView(func(master *bbolt.Bucket) error {
return notes, db.notesUpdate(func(master *bbolt.Bucket) error {
trios := newestBuckets([]*bbolt.Bucket{master}, n, stampKey, nil)
for _, trio := range trios {
note, err := dexdb.DecodeNotification(getCopy(trio.b, noteKey))
Expand All @@ -1844,6 +1844,16 @@ func (db *BoltDB) NotificationsN(n int) ([]*dexdb.Notification, error) {
}
note.Ack = bEqual(trio.b.Get(ackKey), byteTrue)
note.Id = note.ID()
if !bytes.Equal(note.Id, trio.k) {
if !note.Ack {
// This notification was initially stored when the serialization
// and thus note ID did not include the TopicID. Ignore it.
db.log.Tracef("Ignoring stored note with bad key: %x != %x \"%s\"",
[]byte(note.Id), trio.k, note.String())
// trio.b.Put(ackKey, byteTrue)
}
continue
}
notes = append(notes, note)
}
return nil
Expand Down

0 comments on commit e48e3cd

Please sign in to comment.