Skip to content

Commit

Permalink
Log each sync attempt when our blockchain isn't up to date
Browse files Browse the repository at this point in the history
Without this it can appear as though nothing is happening for a while after the app launches.
  • Loading branch information
archived-2 committed Jun 20, 2021
1 parent 2c585a9 commit 227cdc1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/qortal/controller/Synchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,19 @@ public SynchronizationResult synchronize(Peer peer, boolean force) throws Interr
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;
Expand Down

0 comments on commit 227cdc1

Please sign in to comment.