Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: relax some trait bounds #7739

Merged
merged 1 commit into from Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 15 additions & 13 deletions crates/blockchain-tree/src/blockchain_tree.rs
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 5 additions & 9 deletions crates/blockchain-tree/src/shareable.rs
Expand Up @@ -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)) }
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 1 addition & 3 deletions crates/node-builder/src/builder.rs
Expand Up @@ -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,
Expand Down