diff --git a/crates/papyrus_p2p_sync/src/header.rs b/crates/papyrus_p2p_sync/src/header.rs index 441e83fa13..49f3dc1fbd 100644 --- a/crates/papyrus_p2p_sync/src/header.rs +++ b/crates/papyrus_p2p_sync/src/header.rs @@ -8,7 +8,7 @@ use papyrus_storage::header::{HeaderStorageReader, HeaderStorageWriter}; use papyrus_storage::{StorageError, StorageReader, StorageWriter}; use starknet_api::block::BlockNumber; -use crate::stream_factory::{BlockData, BlockNumberLimit, DataStreamFactory}; +use crate::stream_builder::{BlockData, BlockNumberLimit, DataStreamBuilder}; use crate::{P2PSyncError, Response, ALLOWED_SIGNATURES_LENGTH, NETWORK_DATA_TIMEOUT}; impl BlockData for SignedBlockHeader { @@ -33,12 +33,12 @@ impl BlockData for SignedBlockHeader { } } -pub(crate) struct HeaderStreamFactory( +pub(crate) struct HeaderStreamBuilder( PhantomData<(QuerySender, DataReceiver)>, ); -impl DataStreamFactory - for HeaderStreamFactory +impl DataStreamBuilder + for HeaderStreamBuilder where QuerySender: Sink + Unpin + Send + 'static, DataReceiver: Stream> + Unpin + Send + 'static, diff --git a/crates/papyrus_p2p_sync/src/lib.rs b/crates/papyrus_p2p_sync/src/lib.rs index 916b936b9d..07bd41db38 100644 --- a/crates/papyrus_p2p_sync/src/lib.rs +++ b/crates/papyrus_p2p_sync/src/lib.rs @@ -4,7 +4,7 @@ mod header_test; mod state_diff; #[cfg(test)] mod state_diff_test; -mod stream_factory; +mod stream_builder; #[cfg(test)] mod test_utils; @@ -27,9 +27,9 @@ use starknet_api::state::ThinStateDiff; use tokio_stream::StreamExt; use tracing::instrument; -use crate::header::HeaderStreamFactory; -use crate::state_diff::StateDiffStreamFactory; -use crate::stream_factory::DataStreamFactory; +use crate::header::HeaderStreamBuilder; +use crate::state_diff::StateDiffStreamBuilder; +use crate::stream_builder::DataStreamBuilder; const STEP: u64 = 1; const ALLOWED_SIGNATURES_LENGTH: usize = 1; @@ -195,7 +195,7 @@ where #[instrument(skip(self), level = "debug", err)] pub async fn run(mut self) -> Result<(), P2PSyncError> { - let header_stream = HeaderStreamFactory::create_stream( + let header_stream = HeaderStreamBuilder::create_stream( self.header_query_sender.with(|query| ready(Ok(HeaderQuery(query)))), self.header_response_receiver, self.storage_reader.clone(), @@ -204,7 +204,7 @@ where self.config.stop_sync_at_block_number, ); - let state_diff_stream = StateDiffStreamFactory::create_stream( + let state_diff_stream = StateDiffStreamBuilder::create_stream( self.state_diff_query_sender.with(|query| ready(Ok(StateDiffQuery(query)))), self.state_diff_response_receiver, self.storage_reader, diff --git a/crates/papyrus_p2p_sync/src/state_diff.rs b/crates/papyrus_p2p_sync/src/state_diff.rs index 065fa6af53..b7603164c9 100644 --- a/crates/papyrus_p2p_sync/src/state_diff.rs +++ b/crates/papyrus_p2p_sync/src/state_diff.rs @@ -14,7 +14,7 @@ use papyrus_storage::{StorageError, StorageReader, StorageWriter}; use starknet_api::block::BlockNumber; use starknet_api::state::ThinStateDiff; -use crate::stream_factory::{BlockData, BlockNumberLimit, DataStreamFactory}; +use crate::stream_builder::{BlockData, BlockNumberLimit, DataStreamBuilder}; use crate::{P2PSyncError, Response, NETWORK_DATA_TIMEOUT}; impl BlockData for (ThinStateDiff, BlockNumber) { @@ -27,13 +27,13 @@ impl BlockData for (ThinStateDiff, BlockNumber) { } } -pub(crate) struct StateDiffStreamFactory( +pub(crate) struct StateDiffStreamBuilder( PhantomData<(QuerySender, DataReceiver)>, ); // TODO(shahak): Change to StateDiffChunk. -impl DataStreamFactory - for StateDiffStreamFactory +impl DataStreamBuilder + for StateDiffStreamBuilder where QuerySender: Sink + Unpin + Send + 'static, DataReceiver: Stream> + Unpin + Send + 'static, diff --git a/crates/papyrus_p2p_sync/src/stream_factory.rs b/crates/papyrus_p2p_sync/src/stream_builder.rs similarity index 98% rename from crates/papyrus_p2p_sync/src/stream_factory.rs rename to crates/papyrus_p2p_sync/src/stream_builder.rs index 0e16077a49..d7e16ff35f 100644 --- a/crates/papyrus_p2p_sync/src/stream_factory.rs +++ b/crates/papyrus_p2p_sync/src/stream_builder.rs @@ -28,7 +28,7 @@ pub(crate) enum BlockNumberLimit { // TODO(shahak): Add variant for state diff marker once we support classes sync. } -pub(crate) trait DataStreamFactory +pub(crate) trait DataStreamBuilder where QuerySender: Sink + Unpin + Send + 'static, DataReceiver: Stream> + Unpin + Send + 'static,