Skip to content

Commit

Permalink
chore(network): conversion from SyncClientQueryForNetwork to SyncClie…
Browse files Browse the repository at this point in the history
…ntQuery
  • Loading branch information
eitanm-starkware committed Jul 16, 2024
1 parent b348d9f commit 61d773c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/papyrus_network/src/network_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,40 @@ pub fn dummy_report_sender() -> ReportSender {
}

pub type GenericSender<T> = Box<dyn Sink<T, Error = SendError>>;
pub type GenericReceiver<T> = Box<dyn Stream<Item = T>>;
// Box<S> implements Stream only if S: Stream + Unpin
pub type GenericReceiver<T> = Box<dyn Stream<Item = T> + Unpin>;

pub struct SqmrClientQuery<Query, Response: TryFrom<Bytes>> {
pub query: Query,
pub report_receiver: oneshot::Receiver<()>,
pub responses_sender: GenericSender<Result<Response, <Response as TryFrom<Bytes>>::Error>>,
}
// TODO(shahak): Return this type in register_sqmr_protocol_client
pub type SqmrClientChannel<Query, Response> = GenericSender<SqmrClientQuery<Query, Response>>;
pub type SqmrClientSender<Query, Response> = GenericSender<SqmrClientQuery<Query, Response>>;
type SqmrClientReceiver = GenericReceiver<SqmrClientQueryForNetwork>;

pub struct SqmrServerQuery<Query, Response: TryFrom<Bytes>> {
pub query: Query,
pub report_sender: oneshot::Sender<()>,
pub responses_sender: GenericSender<Result<Response, <Response as TryFrom<Bytes>>::Error>>,
}
// TODO(shahak): Return this type in register_sqmr_protocol_server
pub type SqmrServerChannel<Query, Response> = GenericReceiver<SqmrServerQuery<Query, Response>>;
pub type SqmrServerReceiver<Query, Response> = GenericReceiver<SqmrServerQuery<Query, Response>>;
type SqmrServerSender = GenericSender<SqmrServerQueryForNetwork>;

#[allow(dead_code)]
struct SqmrClientQueryForNetwork {
pub query: Bytes,
pub report_receiver: BoxFuture<'static, SessionId>,
pub responses_sender: GenericSender<Bytes>,
}
impl<Query, Response: TryFrom<Bytes>> From<SqmrClientQueryForNetwork>
for SqmrClientQuery<Query, Response>
{
fn from(_query: SqmrClientQueryForNetwork) -> Self {
unimplemented!()
}
}
#[allow(dead_code)]
struct SqmrServerQueryForNetwork {
pub query: Bytes,
Expand Down

0 comments on commit 61d773c

Please sign in to comment.