From 65c26f17df084848391adb578fc93ca068f347be Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sun, 16 May 2021 10:45:40 +0100 Subject: [PATCH] Reduced "Error while trying to find common block with peer" log from INFO to DEBUG when determining which peer to sync with. When performing the actual synchronization, use INFO logging as this is a more serious error. --- .../java/org/qortal/api/resource/PeersResource.java | 2 +- .../java/org/qortal/controller/Synchronizer.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/qortal/api/resource/PeersResource.java b/src/main/java/org/qortal/api/resource/PeersResource.java index 70f0e3e9..244a1569 100644 --- a/src/main/java/org/qortal/api/resource/PeersResource.java +++ b/src/main/java/org/qortal/api/resource/PeersResource.java @@ -321,7 +321,7 @@ public class PeersResource { boolean force = true; List peerBlockSummaries = new ArrayList<>(); - SynchronizationResult findCommonBlockResult = Synchronizer.getInstance().fetchSummariesFromCommonBlock(repository, targetPeer, ourInitialHeight, force, peerBlockSummaries); + SynchronizationResult findCommonBlockResult = Synchronizer.getInstance().fetchSummariesFromCommonBlock(repository, targetPeer, ourInitialHeight, force, peerBlockSummaries, true); if (findCommonBlockResult != SynchronizationResult.OK) return null; diff --git a/src/main/java/org/qortal/controller/Synchronizer.java b/src/main/java/org/qortal/controller/Synchronizer.java index 8876549f..f9a2c9c8 100644 --- a/src/main/java/org/qortal/controller/Synchronizer.java +++ b/src/main/java/org/qortal/controller/Synchronizer.java @@ -178,7 +178,7 @@ public class Synchronizer { ourInitialHeight, Base58.encode(ourLastBlockSignature), ourLatestBlockData.getTimestamp())); List peerBlockSummaries = new ArrayList<>(); - SynchronizationResult findCommonBlockResult = fetchSummariesFromCommonBlock(repository, peer, ourInitialHeight, false, peerBlockSummaries); + SynchronizationResult findCommonBlockResult = fetchSummariesFromCommonBlock(repository, peer, ourInitialHeight, false, peerBlockSummaries, false); if (findCommonBlockResult != SynchronizationResult.OK) { // Logging performed by fetchSummariesFromCommonBlock() above peer.setCommonBlockData(null); @@ -508,7 +508,7 @@ public class Synchronizer { ourInitialHeight, Base58.encode(ourLastBlockSignature), ourLatestBlockData.getTimestamp())); List peerBlockSummaries = new ArrayList<>(); - SynchronizationResult findCommonBlockResult = fetchSummariesFromCommonBlock(repository, peer, ourInitialHeight, force, peerBlockSummaries); + SynchronizationResult findCommonBlockResult = fetchSummariesFromCommonBlock(repository, peer, ourInitialHeight, force, peerBlockSummaries, true); if (findCommonBlockResult != SynchronizationResult.OK) { // Logging performed by fetchSummariesFromCommonBlock() above // Clear our common block cache for this peer @@ -590,7 +590,7 @@ public class Synchronizer { * @throws DataException * @throws InterruptedException */ - public SynchronizationResult fetchSummariesFromCommonBlock(Repository repository, Peer peer, int ourHeight, boolean force, List blockSummariesFromCommon) throws DataException, InterruptedException { + public SynchronizationResult fetchSummariesFromCommonBlock(Repository repository, Peer peer, int ourHeight, boolean force, List blockSummariesFromCommon, boolean infoLogWhenNotFound) throws DataException, InterruptedException { // Start by asking for a few recent block hashes as this will cover a majority of reorgs // Failing that, back off exponentially int step = INITIAL_BLOCK_STEP; @@ -619,8 +619,12 @@ public class Synchronizer { blockSummariesBatch = this.getBlockSummaries(peer, testSignature, step); if (blockSummariesBatch == null) { + if (infoLogWhenNotFound) + LOGGER.info(String.format("Error while trying to find common block with peer %s", peer)); + else + LOGGER.debug(String.format("Error while trying to find common block with peer %s", peer)); + // No response - give up this time - LOGGER.info(String.format("Error while trying to find common block with peer %s", peer)); return SynchronizationResult.NO_REPLY; }