Browse Source

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.
prioritize-peers
CalDescent 3 years ago
parent
commit
c919797553
  1. 12
      src/main/java/org/qortal/controller/Synchronizer.java

12
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 {

Loading…
Cancel
Save