From b4395fdad1579f0db774405268d597e95d8eb066 Mon Sep 17 00:00:00 2001
From: CalDescent <caldescent@protonmail.com>
Date: Sat, 1 May 2021 10:57:24 +0100
Subject: [PATCH] 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.
---
 src/main/java/org/qortal/controller/Synchronizer.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/qortal/controller/Synchronizer.java b/src/main/java/org/qortal/controller/Synchronizer.java
index 21376838..05db6c54 100644
--- a/src/main/java/org/qortal/controller/Synchronizer.java
+++ b/src/main/java/org/qortal/controller/Synchronizer.java
@@ -308,9 +308,10 @@ 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)
-											minChainLength = blockSummaries.size();
+											if (blockSummaries.size() < minChainLength)
+												minChainLength = blockSummaries.size();
 									}
 								}
 							} else {