Skip to content

Commit

Permalink
logging/slotEvent: display block hash if present, empty otherwise (#1705
Browse files Browse the repository at this point in the history
)
  • Loading branch information
q9f authored May 2, 2020
1 parent e11ade0 commit 22e214d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 14 additions & 7 deletions logging/src/main/java/tech/pegasys/teku/logging/EventLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,25 @@ public void syncEvent(

public void slotEvent(
final UnsignedLong nodeSlot,
final UnsignedLong bestSlot,
final UnsignedLong justifiedEpoch,
final UnsignedLong bestBlock,
final Bytes32 bestBlockRoot,
final UnsignedLong nodeEpoch,
final UnsignedLong finalizedEpoch,
final Bytes32 finalizedRoot) {
final Bytes32 finalizedRoot,
final int numPeers) {
String blockRoot = " x ... empty";
if (nodeSlot.equals(bestBlock)) {
blockRoot = shortenHash(bestBlockRoot.toHexString());
}
final String slotEventLog =
String.format(
"Slot Event *** Current slot: %s, Head block: %s, Justified epoch: %s, Finalized epoch: %s, Finalized root: %s",
"Slot Event *** Slot: %s, Block: %s, Epoch: %s, Finalized Epoch: %s, Finalized Root: %s, Peers: %d",
nodeSlot.toString(),
bestSlot.toString(),
justifiedEpoch.toString(),
blockRoot,
nodeEpoch.toString(),
finalizedEpoch.toString(),
shortenHash(finalizedRoot.toHexString()));
shortenHash(finalizedRoot.toHexString()),
numPeers);
info(slotEventLog, Color.WHITE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,11 @@ private void processSlot() {
EVENT_LOG.slotEvent(
nodeSlot.getValue(),
recentChainData.getBestSlot(),
recentChainData.getStore().getJustifiedCheckpoint().getEpoch(),
headBlockRoot,
nodeEpoch,
recentChainData.getStore().getFinalizedCheckpoint().getEpoch(),
recentChainData.getFinalizedRoot());
recentChainData.getFinalizedRoot(),
p2pNetwork.getPeerCount());
this.eventBus.post(new BroadcastAttestationEvent(headBlockRoot, nodeSlot.getValue()));
Thread.sleep(SECONDS_PER_SLOT * 1000 / 3);
this.eventBus.post(new BroadcastAggregatesEvent(nodeSlot.getValue()));
Expand Down

0 comments on commit 22e214d

Please sign in to comment.