Skip to content

Commit

Permalink
impl readstate
Browse files Browse the repository at this point in the history
  • Loading branch information
move47 committed Apr 3, 2024
1 parent 624e273 commit 694814c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async-compatibility-layer = { git = "https://github.com/EspressoSystems/async-co
] }
async-broadcast = "0.7.0"
async-std = { version = "1.9.0", features = ["unstable", "attributes"] }
async-lock = "3.3"
async-lock = "2.8"
async-trait = "0.1"
clap = { version = "4.4", features = ["derive", "env"] }
derive_more = "0.99"
Expand Down
14 changes: 14 additions & 0 deletions src/events_source.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use async_broadcast::{broadcast, Receiver as BroadcastReceiver, Sender as BroadcastSender};
use async_trait::async_trait;
use futures::future::BoxFuture;
use futures::stream::{self, BoxStream, Stream, StreamExt};
use hotshot_types::{
data::{DAProposal, QuorumProposal},
Expand All @@ -11,6 +12,7 @@ use hotshot_types::{
};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use tide_disco::method::ReadState;
const RETAINED_EVENTS_COUNT: usize = 4096;

/// A builder event
Expand Down Expand Up @@ -211,3 +213,15 @@ impl<Types: NodeType> EventsStreamer<Types> {
}
}
}

#[async_trait]
impl<Types: NodeType> ReadState for EventsStreamer<Types> {
type State = Self;

async fn read<T>(
&self,
op: impl Send + for<'a> FnOnce(&'a Self::State) -> BoxFuture<'a, T> + 'async_trait,
) -> T {
op(self).await
}
}

0 comments on commit 694814c

Please sign in to comment.