Fixed bug which could cause minChainLength to report a higher value.

This wouldn't have affected anything in 1.5.0, but it will become more significant if we switch to same-length chain weight comparisons.
This commit is contained in:
CalDescent 2021-05-01 10:57:24 +01:00
parent 1da8994be7
commit b4395fdad1

View File

@ -308,8 +308,9 @@ public class Synchronizer {
// This could mean that the peer has re-orged. But we still have the same common block, so it's safe to proceed with this set of signatures instead.
LOGGER.debug(String.format("Peer %s returned %d block summar%s instead of expected %d", peer, blockSummaries.size(), (blockSummaries.size() != 1 ? "ies" : "y"), summariesRequired));
// Update minChainLength if we have at least 1 block for this peer. If we don't have any blocks, this peer will be excluded from chain weight comparisons later in the process, so we shouldn't update minChainLength
// Reduce minChainLength if we have at least 1 block for this peer. If we don't have any blocks, this peer will be excluded from chain weight comparisons later in the process, so we shouldn't update minChainLength
if (blockSummaries.size() > 0)
if (blockSummaries.size() < minChainLength)
minChainLength = blockSummaries.size();
}
}