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 Jul 1, 2024
1 parent 19f9af0 commit e21e216
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions crates/papyrus_p2p_sync/src/client/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_factory::{BlockData, BlockNumberLimit, DataStreamBuilder};
use super::{P2PSyncError, ResponseReceiver, ALLOWED_SIGNATURES_LENGTH, NETWORK_DATA_TIMEOUT};

impl BlockData for SignedBlockHeader {
Expand All @@ -30,9 +30,9 @@ impl BlockData for SignedBlockHeader {
}
}

pub(crate) struct HeaderStreamFactory;
pub(crate) struct HeaderStreamBuilder;

impl DataStreamFactory<SignedBlockHeader> for HeaderStreamFactory {
impl DataStreamBuilder<SignedBlockHeader> for HeaderStreamBuilder {
type Output = SignedBlockHeader;

const TYPE_DESCRIPTION: &'static str = "headers";
Expand Down
10 changes: 5 additions & 5 deletions crates/papyrus_p2p_sync/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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_factory::{DataStreamBuilder, DataStreamResult};
use tokio_stream::StreamExt;
use tracing::instrument;

Expand Down Expand Up @@ -183,7 +183,7 @@ impl P2PSyncChannels {
storage_reader: StorageReader,
config: P2PSyncConfig,
) -> impl Stream<Item = DataStreamResult> + 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(),
Expand All @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions crates/papyrus_p2p_sync/src/client/state_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_factory::{BlockData, BlockNumberLimit, DataStreamBuilder};
use super::{P2PSyncError, ResponseReceiver, NETWORK_DATA_TIMEOUT};

impl BlockData for (ThinStateDiff, BlockNumber) {
Expand All @@ -24,10 +24,10 @@ impl BlockData for (ThinStateDiff, BlockNumber) {
}
}

pub(crate) struct StateDiffStreamFactory;
pub(crate) struct StateDiffStreamBuilder;

// TODO(shahak): Change to StateDiffChunk.
impl DataStreamFactory<ThinStateDiff> for StateDiffStreamFactory {
impl DataStreamBuilder<ThinStateDiff> for StateDiffStreamBuilder {
type Output = (ThinStateDiff, BlockNumber);

const TYPE_DESCRIPTION: &'static str = "state diffs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InputFromNetwork>
pub(crate) trait DataStreamBuilder<InputFromNetwork>
where
InputFromNetwork: Send + 'static,
DataOrFin<InputFromNetwork>: TryFrom<Vec<u8>>,
Expand Down

0 comments on commit e21e216

Please sign in to comment.