Skip to content
/ besu Public
forked from hyperledger/besu

Commit

Permalink
Add debug logging to see why we stop downloading from peer (hyperledg…
Browse files Browse the repository at this point in the history
…er#6885)

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: amsmota <antonio.mota@citi.com>
  • Loading branch information
siladu authored and amsmota committed Apr 16, 2024
1 parent 289f5ed commit cb41867
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@

import java.util.concurrent.CompletionStage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FastSyncDownloadPipelineFactory implements DownloadPipelineFactory {
private static final Logger LOG = LoggerFactory.getLogger(FastSyncDownloadPipelineFactory.class);

protected final SynchronizerConfiguration syncConfig;
protected final ProtocolSchedule protocolSchedule;
protected final ProtocolContext protocolContext;
Expand Down Expand Up @@ -172,6 +177,18 @@ protected BlockHeader getCommonAncestor(final SyncTarget syncTarget) {
protected boolean shouldContinueDownloadingFromPeer(
final EthPeer peer, final BlockHeader lastRoundHeader) {
final BlockHeader pivotBlockHeader = fastSyncState.getPivotBlockHeader().get();
return !peer.isDisconnected() && lastRoundHeader.getNumber() < pivotBlockHeader.getNumber();
final boolean shouldContinue =
!peer.isDisconnected() && lastRoundHeader.getNumber() < pivotBlockHeader.getNumber();

if (!shouldContinue && peer.isDisconnected()) {
LOG.debug("Stopping chain download due to disconnected peer {}", peer);
} else if (!shouldContinue && lastRoundHeader.getNumber() >= pivotBlockHeader.getNumber()) {
LOG.debug(
"Stopping chain download as lastRoundHeader={} is not less than pivotBlockHeader={} for peer {}",
lastRoundHeader.getNumber(),
pivotBlockHeader.getNumber(),
peer);
}
return shouldContinue;
}
}

0 comments on commit cb41867

Please sign in to comment.