mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: relax some trait bounds (#7739)
This commit is contained in:
@ -57,7 +57,7 @@ use tracing::{debug, error, info, instrument, trace, warn};
|
||||
/// * [BlockchainTree::make_canonical]: Check if we have the hash of a block that is the current
|
||||
/// canonical head and commit it to db.
|
||||
#[derive(Debug)]
|
||||
pub struct BlockchainTree<DB: Database, EVM: ExecutorFactory> {
|
||||
pub struct BlockchainTree<DB, EVM> {
|
||||
/// The state of the tree
|
||||
///
|
||||
/// Tracks all the chains, the block indices, and the block buffer.
|
||||
@ -75,6 +75,20 @@ pub struct BlockchainTree<DB: Database, EVM: ExecutorFactory> {
|
||||
prune_modes: Option<PruneModes>,
|
||||
}
|
||||
|
||||
impl<DB, EVM> BlockchainTree<DB, EVM> {
|
||||
/// Subscribe to new blocks events.
|
||||
///
|
||||
/// Note: Only canonical blocks are emitted by the tree.
|
||||
pub fn subscribe_canon_state(&self) -> CanonStateNotifications {
|
||||
self.canon_state_notification_sender.subscribe()
|
||||
}
|
||||
|
||||
/// Returns a clone of the sender for the canonical state notifications.
|
||||
pub fn canon_state_notification_sender(&self) -> CanonStateNotificationSender {
|
||||
self.canon_state_notification_sender.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB, EVM> BlockchainTree<DB, EVM>
|
||||
where
|
||||
DB: Database + Clone,
|
||||
@ -1104,18 +1118,6 @@ where
|
||||
Ok(outcome)
|
||||
}
|
||||
|
||||
/// Subscribe to new blocks events.
|
||||
///
|
||||
/// Note: Only canonical blocks are emitted by the tree.
|
||||
pub fn subscribe_canon_state(&self) -> CanonStateNotifications {
|
||||
self.canon_state_notification_sender.subscribe()
|
||||
}
|
||||
|
||||
/// Returns a clone of the sender for the canonical state notifications.
|
||||
pub fn canon_state_notification_sender(&self) -> CanonStateNotificationSender {
|
||||
self.canon_state_notification_sender.clone()
|
||||
}
|
||||
|
||||
/// Write the given chain to the database as canonical.
|
||||
fn commit_canonical_to_database(
|
||||
&self,
|
||||
|
||||
@ -25,18 +25,14 @@ use std::{
|
||||
};
|
||||
use tracing::trace;
|
||||
|
||||
/// Shareable blockchain tree that is behind tokio::RwLock
|
||||
/// Shareable blockchain tree that is behind a RwLock
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ShareableBlockchainTree<DB: Database + Clone, EF: ExecutorFactory> {
|
||||
pub struct ShareableBlockchainTree<DB, EF> {
|
||||
/// BlockchainTree
|
||||
pub tree: Arc<RwLock<BlockchainTree<DB, EF>>>,
|
||||
}
|
||||
|
||||
impl<DB, EF> ShareableBlockchainTree<DB, EF>
|
||||
where
|
||||
DB: Database + Clone,
|
||||
EF: ExecutorFactory,
|
||||
{
|
||||
impl<DB, EF> ShareableBlockchainTree<DB, EF> {
|
||||
/// Create a new shareable database.
|
||||
pub fn new(tree: BlockchainTree<DB, EF>) -> Self {
|
||||
Self { tree: Arc::new(RwLock::new(tree)) }
|
||||
@ -202,8 +198,8 @@ where
|
||||
|
||||
impl<DB, EF> CanonStateSubscriptions for ShareableBlockchainTree<DB, EF>
|
||||
where
|
||||
DB: Database + Clone,
|
||||
EF: ExecutorFactory,
|
||||
DB: Send + Sync,
|
||||
EF: Send + Sync,
|
||||
{
|
||||
fn subscribe_to_canonical_state(&self) -> reth_provider::CanonStateNotifications {
|
||||
trace!(target: "blockchain_tree", "Registered subscriber for canonical state");
|
||||
|
||||
@ -44,9 +44,7 @@ use reth_node_core::{
|
||||
primitives::{kzg::KzgSettings, Head},
|
||||
utils::write_peers_to_file,
|
||||
};
|
||||
use reth_node_events::node;
|
||||
|
||||
use reth_node_events::cl::ConsensusLayerHealthEvents;
|
||||
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
|
||||
use reth_primitives::{constants::eip4844::MAINNET_KZG_TRUSTED_SETUP, format_ether, ChainSpec};
|
||||
use reth_provider::{
|
||||
providers::BlockchainProvider, CanonStateSubscriptions, ChainSpecProvider, ProviderFactory,
|
||||
|
||||
Reference in New Issue
Block a user