feat(provider): implement ForkChoiceSubscriptions for BlockchainProvider2 (#10318)

This commit is contained in:
unitezen
2024-08-20 14:22:08 +07:00
committed by GitHub
parent 32fb61337f
commit 387ce3efae

View File

@@ -8,7 +8,10 @@ use crate::{
StaticFileProviderFactory, TransactionVariant, TransactionsProvider, WithdrawalsProvider,
};
use alloy_rpc_types_engine::ForkchoiceState;
use reth_chain_state::{BlockState, CanonicalInMemoryState, MemoryOverlayStateProvider};
use reth_chain_state::{
BlockState, CanonicalInMemoryState, ForkChoiceNotifications, ForkChoiceSubscriptions,
MemoryOverlayStateProvider,
};
use reth_chainspec::{ChainInfo, ChainSpec};
use reth_db_api::{
database::Database,
@@ -1428,6 +1431,21 @@ where
}
}
impl<DB> ForkChoiceSubscriptions for BlockchainProvider2<DB>
where
DB: Send + Sync,
{
fn subscribe_to_safe_block(&self) -> ForkChoiceNotifications {
let receiver = self.canonical_in_memory_state.subscribe_safe_block();
ForkChoiceNotifications(receiver)
}
fn subscribe_to_finalized_block(&self) -> ForkChoiceNotifications {
let receiver = self.canonical_in_memory_state.subscribe_finalized_block();
ForkChoiceNotifications(receiver)
}
}
impl<DB> ChangeSetReader for BlockchainProvider2<DB>
where
DB: Database,