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(network): conversion from SyncClientQueryForNetwork to SyncClient #2230

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
43 changes: 33 additions & 10 deletions crates/papyrus_network/src/network_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,32 +614,55 @@ 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 struct SqmrClientPayload<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 struct SqmrServerQuery<Query, Response: TryFrom<Bytes>> {
pub struct SqmrServerPayload<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>>;

#[allow(dead_code)]
struct SqmrClientQueryForNetwork {
struct SqmrClientPayloadForNetwork {
pub query: Bytes,
pub report_receiver: BoxFuture<'static, SessionId>,
pub responses_sender: GenericSender<Bytes>,
}

// TODO(shahak): Return this type in register_sqmr_protocol_client
pub type SqmrClientSender<Query, Response> = GenericSender<SqmrClientPayload<Query, Response>>;
#[allow(dead_code)]
type SqmrClientReceiver = GenericReceiver<SqmrClientPayloadForNetwork>;

// TODO(shahak): Return this type in register_sqmr_protocol_server
pub type SqmrServerReceiver<Query, Response> = GenericReceiver<SqmrServerPayload<Query, Response>>;
#[allow(dead_code)]
type SqmrServerSender = GenericSender<SqmrServerPayloadForNetwork>;

impl<Query, Response: TryFrom<Bytes>> From<SqmrClientPayload<Query, Response>>
for SqmrClientPayloadForNetwork
{
fn from(_query: SqmrClientPayload<Query, Response>) -> Self {
unimplemented!()
}
}

impl<Query, Response: TryFrom<Bytes>> From<SqmrServerPayloadForNetwork>
for SqmrServerPayload<Query, Response>
{
fn from(_query: SqmrServerPayloadForNetwork) -> Self {
unimplemented!()
}
}

#[allow(dead_code)]
struct SqmrServerQueryForNetwork {
struct SqmrServerPayloadForNetwork {
pub query: Bytes,
pub report_sender: oneshot::Sender<()>,
pub responses_sender: GenericSender<Bytes>,
Expand Down
Loading