mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: Integrate Sealedblock to BeaconConsensusEngineEvent (#2764)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -81,11 +81,11 @@ impl NodeState {
|
||||
BeaconConsensusEngineEvent::ForkchoiceUpdated(state) => {
|
||||
info!(target: "reth::cli", ?state, "Forkchoice updated");
|
||||
}
|
||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(number, hash) => {
|
||||
info!(target: "reth::cli", number, ?hash, "Block added to canonical chain");
|
||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(block) => {
|
||||
info!(target: "reth::cli", number=block.number, hash=?block.hash, "Block added to canonical chain");
|
||||
}
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(number, hash) => {
|
||||
info!(target: "reth::cli", number, ?hash, "Block added to fork chain");
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(block) => {
|
||||
info!(target: "reth::cli", number=block.number, hash=?block.hash, "Block added to fork chain");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use reth_interfaces::consensus::ForkchoiceState;
|
||||
use reth_primitives::{BlockHash, BlockNumber};
|
||||
use reth_primitives::SealedBlock;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Events emitted by [crate::BeaconConsensusEngine].
|
||||
#[derive(Clone, Debug)]
|
||||
@ -7,7 +8,7 @@ pub enum BeaconConsensusEngineEvent {
|
||||
/// The fork choice state was updated.
|
||||
ForkchoiceUpdated(ForkchoiceState),
|
||||
/// A block was added to the canonical chain.
|
||||
CanonicalBlockAdded(BlockNumber, BlockHash),
|
||||
CanonicalBlockAdded(Arc<SealedBlock>),
|
||||
/// A block was added to the fork chain.
|
||||
ForkBlockAdded(BlockNumber, BlockHash),
|
||||
ForkBlockAdded(Arc<SealedBlock>),
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ use reth_tasks::TaskSpawner;
|
||||
use schnellru::{ByLength, LruMap};
|
||||
use std::{
|
||||
pin::Pin,
|
||||
sync::Arc,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
use tokio::sync::{
|
||||
@ -708,22 +709,17 @@ where
|
||||
debug_assert!(self.sync.is_pipeline_idle(), "pipeline must be idle");
|
||||
|
||||
let block_hash = block.hash;
|
||||
let block_number = block.number;
|
||||
let status = self.blockchain.insert_block_without_senders(block)?;
|
||||
let status = self.blockchain.insert_block_without_senders(block.clone())?;
|
||||
let mut latest_valid_hash = None;
|
||||
let block = Arc::new(block);
|
||||
let status = match status {
|
||||
BlockStatus::Valid => {
|
||||
latest_valid_hash = Some(block_hash);
|
||||
self.listeners.notify(BeaconConsensusEngineEvent::CanonicalBlockAdded(
|
||||
block_number,
|
||||
block_hash,
|
||||
));
|
||||
|
||||
self.listeners.notify(BeaconConsensusEngineEvent::CanonicalBlockAdded(block));
|
||||
PayloadStatusEnum::Valid
|
||||
}
|
||||
BlockStatus::Accepted => {
|
||||
self.listeners
|
||||
.notify(BeaconConsensusEngineEvent::ForkBlockAdded(block_number, block_hash));
|
||||
self.listeners.notify(BeaconConsensusEngineEvent::ForkBlockAdded(block));
|
||||
PayloadStatusEnum::Accepted
|
||||
}
|
||||
BlockStatus::Disconnected => PayloadStatusEnum::Syncing,
|
||||
|
||||
Reference in New Issue
Block a user