mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: update sync state based on chain event (#9695)
This commit is contained in:
@ -8,7 +8,7 @@ use reth_beacon_consensus::{
|
||||
use reth_ethereum_engine::service::{ChainEvent, EthService};
|
||||
use reth_ethereum_engine_primitives::EthEngineTypes;
|
||||
use reth_exex::ExExManagerHandle;
|
||||
use reth_network::NetworkEvents;
|
||||
use reth_network::{NetworkEvents, NetworkSyncUpdater, SyncState};
|
||||
use reth_node_api::{FullNodeTypes, NodeAddOns};
|
||||
use reth_node_builder::{
|
||||
hooks::NodeHooks,
|
||||
@ -233,6 +233,7 @@ where
|
||||
.await?;
|
||||
|
||||
// Run consensus engine to completion
|
||||
let network_handle = ctx.components().network().clone();
|
||||
let (tx, rx) = oneshot::channel();
|
||||
info!(target: "reth::cli", "Starting consensus engine");
|
||||
ctx.task_executor().spawn_critical_blocking("consensus engine", async move {
|
||||
@ -245,7 +246,12 @@ where
|
||||
while let Some(event) = eth_service.next().await {
|
||||
debug!(target: "reth::cli", "Event: {event:?}");
|
||||
match event {
|
||||
ChainEvent::BackfillSyncFinished | ChainEvent::BackfillSyncStarted => {}
|
||||
ChainEvent::BackfillSyncFinished => {
|
||||
network_handle.update_sync_state(SyncState::Idle);
|
||||
}
|
||||
ChainEvent::BackfillSyncStarted => {
|
||||
network_handle.update_sync_state(SyncState::Syncing);
|
||||
}
|
||||
ChainEvent::FatalError => break,
|
||||
ChainEvent::Handler(ev) => {
|
||||
event_sender.notify(ev);
|
||||
|
||||
@ -149,12 +149,12 @@ pub use session::{
|
||||
SessionManager,
|
||||
};
|
||||
|
||||
pub use transactions::{FilterAnnouncement, MessageFilter, ValidateTx68};
|
||||
|
||||
pub use flattened_response::FlattenedResponse;
|
||||
pub use manager::DiscoveredEvent;
|
||||
pub use metrics::TxTypesCounter;
|
||||
pub use reth_eth_wire::{DisconnectReason, HelloMessageWithProtocols};
|
||||
pub use reth_network_p2p::sync::{NetworkSyncUpdater, SyncState};
|
||||
pub use reth_network_types::{PeersConfig, SessionsConfig};
|
||||
pub use session::EthRlpxConnection;
|
||||
pub use swarm::NetworkConnectionState;
|
||||
pub use transactions::{FilterAnnouncement, MessageFilter, ValidateTx68};
|
||||
|
||||
Reference in New Issue
Block a user