Files
reth/crates/interfaces/src/events.rs
2023-02-19 19:41:37 +01:00

22 lines
737 B
Rust

use reth_primitives::{Header, H256};
use std::sync::Arc;
use tokio::sync::mpsc::UnboundedReceiver;
/// Type alias for a receiver that receives [NewBlockNotification]
pub type NewBlockNotifications = UnboundedReceiver<NewBlockNotification>;
/// A type that allows to register chain related event subscriptions.
pub trait ChainEventSubscriptions: Send + Sync {
/// Get notified when a new block was imported.
fn subscribe_new_blocks(&self) -> NewBlockNotifications;
}
/// A notification that's emitted when a new block was imported.
#[derive(Clone, Debug)]
pub struct NewBlockNotification {
/// Hash of the block that was imported
pub hash: H256,
/// The block header of the new block
pub header: Arc<Header>,
}