forked from Qortal/qortal
Fix for bug which failed to remove peers without block summaries.
The iterator was removing the peer from the "peersSharingCommonBlock" array, when it should have been removing it from the "peers" array. The result was that the bad peer would end up in the final list of good peers, and we could then sync with it when we shouldn't have.
This commit is contained in:
parent
423142d730
commit
ec2af62b4d
@ -337,10 +337,7 @@ public class Synchronizer {
|
|||||||
LOGGER.debug(String.format("Our chain weight based on %d blocks is %s", ourBlockSummaries.size(), formatter.format(ourChainWeight)));
|
LOGGER.debug(String.format("Our chain weight based on %d blocks is %s", ourBlockSummaries.size(), formatter.format(ourChainWeight)));
|
||||||
|
|
||||||
LOGGER.debug(String.format("Listing peers with common block %.8s...", Base58.encode(commonBlockSummary.getSignature())));
|
LOGGER.debug(String.format("Listing peers with common block %.8s...", Base58.encode(commonBlockSummary.getSignature())));
|
||||||
iterator = peersSharingCommonBlock.iterator();
|
for (Peer peer : peersSharingCommonBlock) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Peer peer = (Peer)iterator.next();
|
|
||||||
|
|
||||||
final int peerHeight = peer.getChainTipData().getLastHeight();
|
final int peerHeight = peer.getChainTipData().getLastHeight();
|
||||||
final int peerAdditionalBlocksAfterCommonBlock = peerHeight - commonBlockSummary.getHeight();
|
final int peerAdditionalBlocksAfterCommonBlock = peerHeight - commonBlockSummary.getHeight();
|
||||||
final CommonBlockData peerCommonBlockData = peer.getCommonBlockData();
|
final CommonBlockData peerCommonBlockData = peer.getCommonBlockData();
|
||||||
@ -348,7 +345,7 @@ public class Synchronizer {
|
|||||||
if (peerCommonBlockData == null || peerCommonBlockData.getBlockSummariesAfterCommonBlock() == null || peerCommonBlockData.getBlockSummariesAfterCommonBlock().isEmpty()) {
|
if (peerCommonBlockData == null || peerCommonBlockData.getBlockSummariesAfterCommonBlock() == null || peerCommonBlockData.getBlockSummariesAfterCommonBlock().isEmpty()) {
|
||||||
// No response - remove this peer for now
|
// No response - remove this peer for now
|
||||||
LOGGER.debug(String.format("Peer %s doesn't have any block summaries - removing it from this round", peer));
|
LOGGER.debug(String.format("Peer %s doesn't have any block summaries - removing it from this round", peer));
|
||||||
iterator.remove();
|
peers.remove(peer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user