Skip to content

Improve BucketProcessedTransactions usage

Christopher Schinnerl requested to merge wallet-database into master

Created by: ChrisSchinnerl

This PR fixes 3 potential issues in the wallet related to the processed transactions bucket.

1.) After deleting from the bucket we decrement the sequence number. This avoids gaps being created during a reorg which might lead to the binary search breaking.

2.) Whenever we remove a txn from BucketProcessedTransactions we also remove it from BucketProcessedTxnIndex. This way we can'tt run into issues with txnIDs pointing to nonexistent indices or even indices of the wrong transaction.

3.) Due to the changes in 1) we can now use the sequence number instead of cursor.Last() to find the last processed transaction. Apparently cursor.Last() is unrealiable when used before calling txn.Commit() on a bbolt transaction and might return nil instead of the last entry or even a wrong entry. This causes either no entry to be deleted or the wrong one during a reorg without anyone noticing.

Merge request reports