From 18bda30bb82c14af1b3687b91b4a769e55cfd388 Mon Sep 17 00:00:00 2001 From: eitanm-starkware Date: Mon, 1 Jul 2024 11:53:21 +0300 Subject: [PATCH] chore(sync): rename stream factory to builder --- crates/papyrus_p2p_sync/src/client/header.rs | 6 +++--- crates/papyrus_p2p_sync/src/client/mod.rs | 12 ++++++------ crates/papyrus_p2p_sync/src/client/state_diff.rs | 6 +++--- .../client/{stream_factory.rs => stream_builder.rs} | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) rename crates/papyrus_p2p_sync/src/client/{stream_factory.rs => stream_builder.rs} (99%) diff --git a/crates/papyrus_p2p_sync/src/client/header.rs b/crates/papyrus_p2p_sync/src/client/header.rs index faae09a5c8..3a3ad1262f 100644 --- a/crates/papyrus_p2p_sync/src/client/header.rs +++ b/crates/papyrus_p2p_sync/src/client/header.rs @@ -5,7 +5,7 @@ use papyrus_storage::header::{HeaderStorageReader, HeaderStorageWriter}; use papyrus_storage::{StorageError, StorageReader, StorageWriter}; use starknet_api::block::BlockNumber; -use super::stream_factory::{BlockData, BlockNumberLimit, DataStreamFactory}; +use super::stream_builder::{BlockData, BlockNumberLimit, DataStreamBuilder}; use super::{P2PSyncError, ResponseReceiver, ALLOWED_SIGNATURES_LENGTH, NETWORK_DATA_TIMEOUT}; impl BlockData for SignedBlockHeader { @@ -30,9 +30,9 @@ impl BlockData for SignedBlockHeader { } } -pub(crate) struct HeaderStreamFactory; +pub(crate) struct HeaderStreamBuilder; -impl DataStreamFactory for HeaderStreamFactory { +impl DataStreamBuilder for HeaderStreamBuilder { type Output = SignedBlockHeader; const TYPE_DESCRIPTION: &'static str = "headers"; diff --git a/crates/papyrus_p2p_sync/src/client/mod.rs b/crates/papyrus_p2p_sync/src/client/mod.rs index 55b320ba32..e7f8537d68 100644 --- a/crates/papyrus_p2p_sync/src/client/mod.rs +++ b/crates/papyrus_p2p_sync/src/client/mod.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; @@ -15,7 +15,7 @@ use futures::channel::mpsc::SendError; use futures::future::{ready, Ready}; use futures::sink::With; use futures::{Sink, SinkExt, Stream}; -use header::HeaderStreamFactory; +use header::HeaderStreamBuilder; use papyrus_config::converters::deserialize_seconds_to_duration; use papyrus_config::dumping::{ser_optional_param, ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; @@ -34,8 +34,8 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockNumber, BlockSignature}; use starknet_api::state::ThinStateDiff; use starknet_api::transaction::{Transaction, TransactionOutput}; -use state_diff::StateDiffStreamFactory; -use stream_factory::{DataStreamFactory, DataStreamResult}; +use state_diff::StateDiffStreamBuilder; +use stream_builder::{DataStreamBuilder, DataStreamResult}; use tokio_stream::StreamExt; use tracing::instrument; @@ -183,7 +183,7 @@ impl P2PSyncChannels { storage_reader: StorageReader, config: P2PSyncConfig, ) -> impl Stream + Send + 'static { - 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, storage_reader.clone(), @@ -192,7 +192,7 @@ impl P2PSyncChannels { 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, storage_reader.clone(), diff --git a/crates/papyrus_p2p_sync/src/client/state_diff.rs b/crates/papyrus_p2p_sync/src/client/state_diff.rs index 891c51ae5b..a33f44dfe2 100644 --- a/crates/papyrus_p2p_sync/src/client/state_diff.rs +++ b/crates/papyrus_p2p_sync/src/client/state_diff.rs @@ -11,7 +11,7 @@ use papyrus_storage::{StorageError, StorageReader, StorageWriter}; use starknet_api::block::BlockNumber; use starknet_api::state::ThinStateDiff; -use super::stream_factory::{BlockData, BlockNumberLimit, DataStreamFactory}; +use super::stream_builder::{BlockData, BlockNumberLimit, DataStreamBuilder}; use super::{P2PSyncError, ResponseReceiver, NETWORK_DATA_TIMEOUT}; impl BlockData for (ThinStateDiff, BlockNumber) { @@ -24,10 +24,10 @@ impl BlockData for (ThinStateDiff, BlockNumber) { } } -pub(crate) struct StateDiffStreamFactory; +pub(crate) struct StateDiffStreamBuilder; // TODO(shahak): Change to StateDiffChunk. -impl DataStreamFactory for StateDiffStreamFactory { +impl DataStreamBuilder for StateDiffStreamBuilder { type Output = (ThinStateDiff, BlockNumber); const TYPE_DESCRIPTION: &'static str = "state diffs"; diff --git a/crates/papyrus_p2p_sync/src/client/stream_factory.rs b/crates/papyrus_p2p_sync/src/client/stream_builder.rs similarity index 99% rename from crates/papyrus_p2p_sync/src/client/stream_factory.rs rename to crates/papyrus_p2p_sync/src/client/stream_builder.rs index 88e142ab8e..6b2e6eb6f1 100644 --- a/crates/papyrus_p2p_sync/src/client/stream_factory.rs +++ b/crates/papyrus_p2p_sync/src/client/stream_builder.rs @@ -29,7 +29,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 InputFromNetwork: Send + 'static, DataOrFin: TryFrom>,