mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: Enhance block import log line (#6095)
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
This commit is contained in:
@ -6,11 +6,11 @@ use std::{sync::Arc, time::Duration};
|
||||
/// Events emitted by [crate::BeaconConsensusEngine].
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum BeaconConsensusEngineEvent {
|
||||
/// The fork choice state was updated.
|
||||
/// The fork choice state was updated, and the current fork choice status
|
||||
ForkchoiceUpdated(ForkchoiceState, ForkchoiceStatus),
|
||||
/// A block was added to the canonical chain.
|
||||
CanonicalBlockAdded(Arc<SealedBlock>),
|
||||
/// A canonical chain was committed.
|
||||
/// A block was added to the canonical chain, and the elapsed time validating the block
|
||||
CanonicalBlockAdded(Arc<SealedBlock>, Duration),
|
||||
/// A canonical chain was committed, and the elapsed time committing the data
|
||||
CanonicalChainCommitted(Box<SealedHeader>, Duration),
|
||||
/// A block was added to the fork chain.
|
||||
ForkBlockAdded(Arc<SealedBlock>),
|
||||
|
||||
@ -1271,16 +1271,18 @@ where
|
||||
debug_assert!(self.sync.is_pipeline_idle(), "pipeline must be idle");
|
||||
|
||||
let block_hash = block.hash();
|
||||
let start = Instant::now();
|
||||
let status = self
|
||||
.blockchain
|
||||
.insert_block_without_senders(block.clone(), BlockValidationKind::Exhaustive)?;
|
||||
let elapsed = start.elapsed();
|
||||
let mut latest_valid_hash = None;
|
||||
let block = Arc::new(block);
|
||||
let status = match status {
|
||||
InsertPayloadOk::Inserted(BlockStatus::Valid(attachment)) => {
|
||||
latest_valid_hash = Some(block_hash);
|
||||
let event = if attachment.is_canonical() {
|
||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(block)
|
||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(block, elapsed)
|
||||
} else {
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(block)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user