bdk
bdk copied to clipboard
fix(bitcoind_rpc): fix filter iter may not handle reorgs properly
Description
This PR fixes FilterIter not handling reorgs properly as stated in this issue #1848
Notes to the reviewers z
The code in this fix detects reorgs by checking if the previous_block_hash matches the hash of the previous block in the chain. It then finds the last common block between the old and new chains with the find_fork_point method. And resets the iterator's state to the fork point(i.e. point of reorg) and resume scanning from the new chain.
I also added tests to simulate a reorg and verifythat the iterator correctly switches to the new chain
Changelog notice
Checklists
All Submissions:
- [x] I've signed all my commits
- [x] I followed the contribution guidelines
- [x] I ran
cargo fmtandcargo clippybefore committing
New Features:
- [ ] I've added tests for the new feature
- [ ] I've added docs for the new feature
Bugfixes:
- [ ] This pull request breaks the existing API
- [ ] I've added tests to reproduce the issue which are now passing
- [x] I'm linking the issue being fixed by this PR