Skip to content

Commit

Permalink
chore(sync): rename stream factory to builder
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanm-starkware committed Jun 18, 2024
1 parent 8dfbf74 commit fcfb63b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions crates/papyrus_p2p_sync/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -33,12 +33,12 @@ impl BlockData for SignedBlockHeader {
}
}

pub(crate) struct HeaderStreamFactory<QuerySender, DataReceiver>(
pub(crate) struct HeaderStreamBuilder<QuerySender, DataReceiver>(
PhantomData<(QuerySender, DataReceiver)>,
);

impl<QuerySender, DataReceiver> DataStreamFactory<QuerySender, DataReceiver, SignedBlockHeader>
for HeaderStreamFactory<QuerySender, DataReceiver>
impl<QuerySender, DataReceiver> DataStreamBuilder<QuerySender, DataReceiver, SignedBlockHeader>
for HeaderStreamBuilder<QuerySender, DataReceiver>
where
QuerySender: Sink<Query, Error = SendError> + Unpin + Send + 'static,
DataReceiver: Stream<Item = Response<SignedBlockHeader>> + Unpin + Send + 'static,
Expand Down
12 changes: 6 additions & 6 deletions crates/papyrus_p2p_sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions crates/papyrus_p2p_sync/src/state_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -27,13 +27,13 @@ impl BlockData for (ThinStateDiff, BlockNumber) {
}
}

pub(crate) struct StateDiffStreamFactory<QuerySender, DataReceiver>(
pub(crate) struct StateDiffStreamBuilder<QuerySender, DataReceiver>(
PhantomData<(QuerySender, DataReceiver)>,
);

// TODO(shahak): Change to StateDiffChunk.
impl<QuerySender, DataReceiver> DataStreamFactory<QuerySender, DataReceiver, ThinStateDiff>
for StateDiffStreamFactory<QuerySender, DataReceiver>
impl<QuerySender, DataReceiver> DataStreamBuilder<QuerySender, DataReceiver, ThinStateDiff>
for StateDiffStreamBuilder<QuerySender, DataReceiver>
where
QuerySender: Sink<Query, Error = SendError> + Unpin + Send + 'static,
DataReceiver: Stream<Item = Response<ThinStateDiff>> + Unpin + Send + 'static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<QuerySender, DataReceiver, InputFromNetwork>
pub(crate) trait DataStreamBuilder<QuerySender, DataReceiver, InputFromNetwork>
where
QuerySender: Sink<Query, Error = SendError> + Unpin + Send + 'static,
DataReceiver: Stream<Item = Response<InputFromNetwork>> + Unpin + Send + 'static,
Expand Down

0 comments on commit fcfb63b

Please sign in to comment.