Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/optimism/flashblocks/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ impl<
Builder: PendingEnvBuilder<EvmConfig>,
> FlashBlockService<N, S, EvmConfig, Provider, Builder>
{
/// Constructs a new `FlashBlockService` that receives [`FlashBlock`]s from `rx` stream.
pub const fn new(rx: S, evm_config: EvmConfig, provider: Provider, builder: Builder) -> Self {
Self { rx, current: None, blocks: Vec::new(), evm_config, provider, builder }
}

/// Adds the `block` into the collection.
///
/// Depending on its index and associated block number, it may:
Expand Down
12 changes: 12 additions & 0 deletions crates/optimism/flashblocks/src/ws/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ pub struct FlashBlockWsStream {
stream: Option<SplitStream<WebSocketStream<MaybeTlsStream<TcpStream>>>>,
}

impl FlashBlockWsStream {
/// Creates a new websocket stream over `ws_url`.
pub fn new(ws_url: Url) -> Self {
Self {
ws_url,
state: State::default(),
connect: Box::pin(async move { Err(Error::ConnectionClosed) }),
stream: None,
}
}
}

impl Stream for FlashBlockWsStream {
type Item = eyre::Result<FlashBlock>;

Expand Down