decred / dcrwallet

A secure Decred wallet daemon written in Go (golang).
https://decred.org
ISC License
211 stars 153 forks source link

[release-v2.0] spv: Fix request of new blocks after initial sync #2391

Closed jrick closed 1 week ago

jrick commented 1 week ago

This fixes an issue where SPV wallets would only request blocks from peers after a new block was mined.

The issue could be triggered if the number of peers ever dropped to zero, causing the SPV syncer to consider itself unsynced, and if blocks were mined in the intervening period until a new peer was connected.

The root cause was the addition of the unsynced status on the refactoring made in commit 6cde2cc. That made the sync status atomic decoupled to the state of the initialSyncDone signalling channel, which meant that if the atomic was switched to zero after the initial sync was done, new headers would fail to be requested from newly connected peers.

Upon further review, the check is ultimately unnecessary and is removed in this commit ensuring that, after initial sync is completed, the headers are asked of every peer.

Backport of 794fff4420e481ce7724c70f6c62f5ba1d623edb.