Reduced frequency and level of some synchronizer logs.

This commit is contained in:
CalDescent 2021-05-16 10:36:41 +01:00
parent 1ba64d9745
commit 3bedba71d5
2 changed files with 12 additions and 6 deletions

View File

@ -677,7 +677,7 @@ public class Controller extends Thread {
peers.removeIf(hasInferiorChainTip); peers.removeIf(hasInferiorChainTip);
final int peersRemoved = peersBeforeComparison - peers.size(); final int peersRemoved = peersBeforeComparison - peers.size();
if (peersRemoved > 0) if (peersRemoved > 0 && peers.size() > 0)
LOGGER.info(String.format("Ignoring %d peers on inferior chains. Peers remaining: %d", peersRemoved, peers.size())); LOGGER.info(String.format("Ignoring %d peers on inferior chains. Peers remaining: %d", peersRemoved, peers.size()));
if (peers.isEmpty()) if (peers.isEmpty())

View File

@ -111,6 +111,7 @@ public class Synchronizer {
LOGGER.debug(String.format("Searching for common blocks with %d peers...", peers.size())); LOGGER.debug(String.format("Searching for common blocks with %d peers...", peers.size()));
final long startTime = System.currentTimeMillis(); final long startTime = System.currentTimeMillis();
int commonBlocksFound = 0; int commonBlocksFound = 0;
boolean wereNewRequestsMade = false;
for (Peer peer : peers) { for (Peer peer : peers) {
// Are we shutting down? // Are we shutting down?
@ -131,10 +132,15 @@ public class Synchronizer {
Synchronizer.getInstance().findCommonBlockWithPeer(peer, repository); Synchronizer.getInstance().findCommonBlockWithPeer(peer, repository);
if (peer.getCommonBlockData() != null) if (peer.getCommonBlockData() != null)
commonBlocksFound++; commonBlocksFound++;
// This round wasn't served entirely from the cache, so we may want to log the results
wereNewRequestsMade = true;
} }
final long totalTimeTaken = System.currentTimeMillis() - startTime; if (wereNewRequestsMade) {
LOGGER.info(String.format("Finished searching for common blocks with %d peer%s. Found: %d. Total time taken: %d ms", peers.size(), (peers.size() != 1 ? "s" : ""), commonBlocksFound, totalTimeTaken)); final long totalTimeTaken = System.currentTimeMillis() - startTime;
LOGGER.info(String.format("Finished searching for common blocks with %d peer%s. Found: %d. Total time taken: %d ms", peers.size(), (peers.size() != 1 ? "s" : ""), commonBlocksFound, totalTimeTaken));
}
return SynchronizationResult.OK; return SynchronizationResult.OK;
} finally { } finally {
@ -294,7 +300,7 @@ public class Synchronizer {
if (peer.canUseCachedCommonBlockData()) { if (peer.canUseCachedCommonBlockData()) {
if (peer.getCommonBlockData().getBlockSummariesAfterCommonBlock() != null) { if (peer.getCommonBlockData().getBlockSummariesAfterCommonBlock() != null) {
if (peer.getCommonBlockData().getBlockSummariesAfterCommonBlock().size() == summariesRequired) { if (peer.getCommonBlockData().getBlockSummariesAfterCommonBlock().size() == summariesRequired) {
LOGGER.debug(String.format("Using cached block summaries for peer %s", peer)); LOGGER.trace(String.format("Using cached block summaries for peer %s", peer));
useCachedSummaries = true; useCachedSummaries = true;
} }
} }
@ -434,14 +440,14 @@ public class Synchronizer {
for (Peer peer : peers) { for (Peer peer : peers) {
if (peer.getCommonBlockData() != null && peer.getCommonBlockData().getCommonBlockSummary() != null) { if (peer.getCommonBlockData() != null && peer.getCommonBlockData().getCommonBlockSummary() != null) {
LOGGER.debug(String.format("Peer %s has common block %.8s", peer, Base58.encode(peer.getCommonBlockData().getCommonBlockSummary().getSignature()))); LOGGER.trace(String.format("Peer %s has common block %.8s", peer, Base58.encode(peer.getCommonBlockData().getCommonBlockSummary().getSignature())));
BlockSummaryData commonBlockSummary = peer.getCommonBlockData().getCommonBlockSummary(); BlockSummaryData commonBlockSummary = peer.getCommonBlockData().getCommonBlockSummary();
if (!commonBlocks.contains(commonBlockSummary)) if (!commonBlocks.contains(commonBlockSummary))
commonBlocks.add(commonBlockSummary); commonBlocks.add(commonBlockSummary);
} }
else { else {
LOGGER.debug(String.format("Peer %s has no common block data. Skipping...", peer)); LOGGER.trace(String.format("Peer %s has no common block data. Skipping...", peer));
} }
} }