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.
This commit is contained in:
CalDescent 2021-04-17 13:09:52 +01:00
parent 08dacab05c
commit c919797553

View File

@ -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, LOGGER.info(String.format("Peer %s failed to respond with more block signatures after height %d, sig %.8s", peer,
height, Base58.encode(latestPeerSignature))); height, Base58.encode(latestPeerSignature)));
// If we have already received blocks from this peer, go ahead and apply them // We need to fully synchronize, so give up and move on to the next peer
if (peerBlocks.size() > 0) {
break;
}
// Otherwise, give up and move on to the next peer
return SynchronizationResult.NO_REPLY; return SynchronizationResult.NO_REPLY;
} }
@ -790,11 +786,7 @@ public class Synchronizer {
if (retryCount >= MAXIMUM_RETRIES) { if (retryCount >= MAXIMUM_RETRIES) {
// If we have already received blocks from this peer, go ahead and apply them // We need to fully synchronize, so give up and move on to the next peer
if (peerBlocks.size() > 0) {
break;
}
// Otherwise, give up and move on to the next peer
return SynchronizationResult.NO_REPLY; return SynchronizationResult.NO_REPLY;
} else { } else {