chain: Request block ntfns only after initial sync #2310
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, request for notifications about connected blocks were sent to the underlying dcrd instance before the chain was fully synced. This could cause a race issue if the underlying dcrd instance was also performing an initial sync, causing blocks to be connected by the blockConnected handler before the active data filter was loaded, causing transactions to be missed and the wallet's balance to be wrong, requiring a rescan to be fixed.
This could happen, for example, if both the dcrd and dcrwallet processes were started at the same time or if dcrd took just enough time to connect to the network that the wallet was also initialized (for exemple, from within Decrediton).
This fixes the issue by refactoring the initial sync code to only request block notifications after the initial header sync has been completed by the wallet.
Note that, despite a large(ish) diff, this is mostly a code move PR.
One way to reproduce the above issue in simnet is the following:
wallet3
)wallet3
wallet1
to the previously generatedwallet3
addresswallet3
with the diff applied