decred / dcrwallet

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

spv: Fix request of new blocks after initial sync #2390

Closed matheusd closed 2 weeks ago

matheusd commented 2 weeks 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 6cde2cc7. 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.