From 227cdc1ec840e64c6b095f883ce76ebb76bf4180 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sun, 20 Jun 2021 07:25:25 +0100 Subject: [PATCH] Log each sync attempt when our blockchain isn't up to date Without this it can appear as though nothing is happening for a while after the app launches. --- .../java/org/qortal/controller/Synchronizer.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/qortal/controller/Synchronizer.java b/src/main/java/org/qortal/controller/Synchronizer.java index 9f874708..113af107 100644 --- a/src/main/java/org/qortal/controller/Synchronizer.java +++ b/src/main/java/org/qortal/controller/Synchronizer.java @@ -509,9 +509,19 @@ public class Synchronizer { byte[] peersLastBlockSignature = peerChainTipData.getLastBlockSignature(); byte[] ourLastBlockSignature = ourLatestBlockData.getSignature(); - LOGGER.debug(String.format("Synchronizing with peer %s at height %d, sig %.8s, ts %d; our height %d, sig %.8s, ts %d", peer, + String syncString = String.format("Synchronizing with peer %s at height %d, sig %.8s, ts %d; our height %d, sig %.8s, ts %d", peer, peerHeight, Base58.encode(peersLastBlockSignature), peer.getChainTipData().getLastBlockTimestamp(), - ourInitialHeight, Base58.encode(ourLastBlockSignature), ourLatestBlockData.getTimestamp())); + ourInitialHeight, Base58.encode(ourLastBlockSignature), ourLatestBlockData.getTimestamp()); + + // If our latest block is very old, we should log that we're attempting to sync with a peer + // Otherwise, it can appear as though nothing is happening for a while after launch + final Long minLatestBlockTimestamp = Controller.getMinimumLatestBlockTimestamp(); + if (minLatestBlockTimestamp != null && ourLatestBlockData.getTimestamp() < minLatestBlockTimestamp) { + LOGGER.info(syncString); + } + else { + LOGGER.debug(syncString); + } // Reset last re-org size as we are starting a new sync round this.lastReorgSize = 0;