mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-25 15:10:18 +01:00
Peer: drop out of fast catchup mode when reaching the top of the chain.
This bug could cause problems if you sync a wallet containing no keys, and then a chain fork happens (you won't follow the fork).
This commit is contained in:
parent
2acbd55d47
commit
81a9e1e893
1 changed files with 6 additions and 1 deletions
|
@ -422,7 +422,12 @@ public class Peer {
|
|||
checkState(!downloadBlockBodies, toString());
|
||||
for (int i = 0; i < m.getBlockHeaders().size(); i++) {
|
||||
Block header = m.getBlockHeaders().get(i);
|
||||
if (header.getTimeSeconds() < fastCatchupTimeSecs) {
|
||||
// Process headers until we pass the fast catchup time, or are about to catch up with the head
|
||||
// of the chain - always process the last block as a full/filtered block to kick us out of the
|
||||
// fast catchup mode (in which we ignore new blocks).
|
||||
boolean passedTime = header.getTimeSeconds() >= fastCatchupTimeSecs;
|
||||
boolean reachedTop = blockChain.getBestChainHeight() >= vPeerVersionMessage.bestHeight;
|
||||
if (!passedTime && !reachedTop) {
|
||||
if (!vDownloadData) {
|
||||
// Not download peer anymore, some other peer probably became better.
|
||||
log.info("Lost download peer status, throwing away downloaded headers.");
|
||||
|
|
Loading…
Add table
Reference in a new issue