mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add CanonStateSubscriptions to NoopTree (#7828)
This commit is contained in:
@ -22,7 +22,10 @@ use std::collections::{BTreeMap, HashSet};
|
|||||||
/// Caution: this is only intended for testing purposes, or for wiring components together.
|
/// Caution: this is only intended for testing purposes, or for wiring components together.
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct NoopBlockchainTree {}
|
pub struct NoopBlockchainTree {
|
||||||
|
/// Broadcast channel for canon state changes notifications.
|
||||||
|
pub canon_state_notification_sender: Option<CanonStateNotificationSender>,
|
||||||
|
}
|
||||||
|
|
||||||
impl BlockchainTreeEngine for NoopBlockchainTree {
|
impl BlockchainTreeEngine for NoopBlockchainTree {
|
||||||
fn buffer_block(&self, _block: SealedBlockWithSenders) -> Result<(), InsertBlockError> {
|
fn buffer_block(&self, _block: SealedBlockWithSenders) -> Result<(), InsertBlockError> {
|
||||||
@ -127,6 +130,9 @@ impl BlockchainTreePendingStateProvider for NoopBlockchainTree {
|
|||||||
|
|
||||||
impl CanonStateSubscriptions for NoopBlockchainTree {
|
impl CanonStateSubscriptions for NoopBlockchainTree {
|
||||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications {
|
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications {
|
||||||
CanonStateNotificationSender::new(1).subscribe()
|
self.canon_state_notification_sender
|
||||||
|
.as_ref()
|
||||||
|
.map(|sender| sender.subscribe())
|
||||||
|
.unwrap_or_else(|| CanonStateNotificationSender::new(1).subscribe())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user