From c919797553754f6d7277123323d981919c96c98f Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sat, 17 Apr 2021 13:09:52 +0100 Subject: [PATCH] When syncing to a peer on a different fork, ensure that all blocks are obtained before applying them. In version 1.4.6, we would still sync with a peer even if we only received a partial number of the requested blocks/summaries. This could create a new problem, because the BlockMinter would often try and make up the difference by minting a new fork of up to 5 blocks in quick succession. This could have added to network confusion. Longer term we may want to adjust the BlockMinter code to prevent this from taking place altogether, but in the short term I will revert this change from 1.4.6 until we have a better way. --- .../java/org/qortal/controller/Synchronizer.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/qortal/controller/Synchronizer.java b/src/main/java/org/qortal/controller/Synchronizer.java index 94a3a644..b5aa31d3 100644 --- a/src/main/java/org/qortal/controller/Synchronizer.java +++ b/src/main/java/org/qortal/controller/Synchronizer.java @@ -761,11 +761,7 @@ public class Synchronizer { LOGGER.info(String.format("Peer %s failed to respond with more block signatures after height %d, sig %.8s", peer, height, Base58.encode(latestPeerSignature))); - // If we have already received blocks from this peer, go ahead and apply them - if (peerBlocks.size() > 0) { - break; - } - // Otherwise, give up and move on to the next peer + // We need to fully synchronize, so give up and move on to the next peer return SynchronizationResult.NO_REPLY; } @@ -790,11 +786,7 @@ public class Synchronizer { if (retryCount >= MAXIMUM_RETRIES) { - // If we have already received blocks from this peer, go ahead and apply them - if (peerBlocks.size() > 0) { - break; - } - // Otherwise, give up and move on to the next peer + // We need to fully synchronize, so give up and move on to the next peer return SynchronizationResult.NO_REPLY; } else {