Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sync): rename stream factory to builder #2119

Merged
merged 1 commit into from
Jul 1, 2024
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
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_builder::{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
12 changes: 6 additions & 6 deletions crates/papyrus_p2p_sync/src/client/mod.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 @@ -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_builder::{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_builder::{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
Loading