Fix race condition after reorg #29

Merged
roylee17 merged 2 commits from roylee/fix-race-condition-after-reorg into master 2022-09-13 20:40:06 +02:00
roylee17 commented 2022-09-13 20:24:34 +02:00 (Migrated from github.com)

Fix #28

This PR solves to issues:

  1. The rollback code, which handles disconnected blocks, did not save the hash to the w.manager.SyncedTo status. Seems like a bug caused by a typo - b.hash vs bs.Hash

  2. Handle corner cases where the chain has reorged to a lower height than the wallet had synced to.
    This could happen if the chain has reorged to a shorter chain with difficulty greater than the current main chain.
    The wallet won't be able to sync before the reorged chain grows past the previous main chain's height.

Fix #28 This PR solves to issues: 1. The rollback code, which handles disconnected blocks, did not save the hash to the `w.manager.SyncedTo` status. Seems like a bug caused by a typo - `b.hash vs bs.Hash` 2. Handle corner cases where the chain has reorged to a lower height than the wallet had synced to. This could happen if the chain has reorged to a shorter chain with difficulty greater than the current main chain. The wallet won't be able to sync before the reorged chain grows past the previous main chain's height.
Sign in to join this conversation.
No description provided.