mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add ChainEventSubscriptions trait (#1338)
This commit is contained in:
21
crates/interfaces/src/events.rs
Normal file
21
crates/interfaces/src/events.rs
Normal file
@ -0,0 +1,21 @@
|
||||
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 {
|
||||
/// 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>,
|
||||
}
|
||||
@ -7,29 +7,31 @@
|
||||
|
||||
//! Reth interface bindings
|
||||
|
||||
/// Block Execution traits.
|
||||
pub mod executor;
|
||||
|
||||
/// Consensus traits.
|
||||
pub mod consensus;
|
||||
|
||||
/// Provider error
|
||||
pub mod provider;
|
||||
|
||||
/// Database error
|
||||
pub mod db;
|
||||
|
||||
/// Block Execution traits.
|
||||
pub mod executor;
|
||||
|
||||
/// Possible errors when interacting with the chain.
|
||||
mod error;
|
||||
pub use error::{Error, Result};
|
||||
|
||||
/// Traits for subscribing to events.
|
||||
pub mod events;
|
||||
|
||||
/// P2P traits.
|
||||
pub mod p2p;
|
||||
|
||||
/// Provider error
|
||||
pub mod provider;
|
||||
|
||||
/// Syncing related traits.
|
||||
pub mod sync;
|
||||
|
||||
/// Possible errors when interacting with the chain.
|
||||
mod error;
|
||||
|
||||
pub use error::{Error, Result};
|
||||
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
/// Common test helpers for mocking out Consensus, Downloaders and Header Clients.
|
||||
pub mod test_utils;
|
||||
|
||||
Reference in New Issue
Block a user