mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix(bin): latest block in status message (#4856)
This commit is contained in:
@ -34,18 +34,18 @@ struct NodeState {
|
|||||||
eta: Eta,
|
eta: Eta,
|
||||||
/// The current checkpoint of the executing stage.
|
/// The current checkpoint of the executing stage.
|
||||||
current_checkpoint: StageCheckpoint,
|
current_checkpoint: StageCheckpoint,
|
||||||
/// The latest canonical block added in the consensus engine.
|
/// The latest block reached by either pipeline or consensus engine.
|
||||||
latest_canonical_engine_block: Option<BlockNumber>,
|
latest_block: Option<BlockNumber>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NodeState {
|
impl NodeState {
|
||||||
fn new(network: Option<NetworkHandle>, latest_block_number: Option<BlockNumber>) -> Self {
|
fn new(network: Option<NetworkHandle>, latest_block: Option<BlockNumber>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
network,
|
network,
|
||||||
current_stage: None,
|
current_stage: None,
|
||||||
eta: Eta::default(),
|
eta: Eta::default(),
|
||||||
current_checkpoint: StageCheckpoint::new(0),
|
current_checkpoint: StageCheckpoint::new(0),
|
||||||
latest_canonical_engine_block: latest_block_number,
|
latest_block,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +79,9 @@ impl NodeState {
|
|||||||
result: ExecOutput { checkpoint, done },
|
result: ExecOutput { checkpoint, done },
|
||||||
} => {
|
} => {
|
||||||
self.current_checkpoint = checkpoint;
|
self.current_checkpoint = checkpoint;
|
||||||
|
if stage_id.is_finish() {
|
||||||
|
self.latest_block = Some(checkpoint.block_number);
|
||||||
|
}
|
||||||
self.eta.update(self.current_checkpoint);
|
self.eta.update(self.current_checkpoint);
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
@ -124,11 +127,11 @@ impl NodeState {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(block) => {
|
BeaconConsensusEngineEvent::CanonicalBlockAdded(block) => {
|
||||||
self.latest_canonical_engine_block = Some(block.number);
|
|
||||||
|
|
||||||
info!(number=block.number, hash=?block.hash, "Block added to canonical chain");
|
info!(number=block.number, hash=?block.hash, "Block added to canonical chain");
|
||||||
}
|
}
|
||||||
BeaconConsensusEngineEvent::CanonicalChainCommitted(head, elapsed) => {
|
BeaconConsensusEngineEvent::CanonicalChainCommitted(head, elapsed) => {
|
||||||
|
self.latest_block = Some(head.number);
|
||||||
|
|
||||||
info!(number=head.number, hash=?head.hash, ?elapsed, "Canonical chain committed");
|
info!(number=head.number, hash=?head.hash, ?elapsed, "Canonical chain committed");
|
||||||
}
|
}
|
||||||
BeaconConsensusEngineEvent::ForkBlockAdded(block) => {
|
BeaconConsensusEngineEvent::ForkBlockAdded(block) => {
|
||||||
@ -270,7 +273,7 @@ where
|
|||||||
info!(
|
info!(
|
||||||
target: "reth::cli",
|
target: "reth::cli",
|
||||||
connected_peers = this.state.num_connected_peers(),
|
connected_peers = this.state.num_connected_peers(),
|
||||||
latest_block = this.state.latest_canonical_engine_block.unwrap_or(this.state.current_checkpoint.block_number),
|
latest_block = ?this.state.latest_block,
|
||||||
"Status"
|
"Status"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user