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

Implement NetworkRequest for litep2p #7073

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
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
26 changes: 18 additions & 8 deletions substrate/client/network/src/litep2p/service.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also enable the litep2p request-response benchmark in substrate/client/network/benches/request_response_protocol.rs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, I just didn't want to mix it in one PR

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use crate::{
peer_store::PeerStoreProvider,
service::out_events,
Event, IfDisconnected, NetworkDHTProvider, NetworkEventStream, NetworkPeers, NetworkRequest,
NetworkSigner, NetworkStateInfo, NetworkStatus, NetworkStatusProvider, ProtocolName,
RequestFailure, Signature,
NetworkSigner, NetworkStateInfo, NetworkStatus, NetworkStatusProvider, OutboundFailure,
ProtocolName, RequestFailure, Signature,
};

use codec::DecodeAll;
Expand Down Expand Up @@ -526,13 +526,23 @@ impl NetworkStateInfo for Litep2pNetworkService {
impl NetworkRequest for Litep2pNetworkService {
async fn request(
&self,
_target: PeerId,
_protocol: ProtocolName,
_request: Vec<u8>,
_fallback_request: Option<(Vec<u8>, ProtocolName)>,
_connect: IfDisconnected,
target: PeerId,
protocol: ProtocolName,
request: Vec<u8>,
fallback_request: Option<(Vec<u8>, ProtocolName)>,
connect: IfDisconnected,
) -> Result<(Vec<u8>, ProtocolName), RequestFailure> {
unimplemented!();
let (tx, rx) = oneshot::channel();

self.start_request(target, protocol, request, fallback_request, tx, connect);

match rx.await {
Ok(v) => v,
// The channel can only be closed if the network worker no longer exists. If the
// network worker no longer exists, then all connections to `target` are necessarily
// closed, and we legitimately report this situation as a "ConnectionClosed".
Err(_) => Err(RequestFailure::Network(OutboundFailure::ConnectionClosed)),
}
}

fn start_request(
Expand Down
Loading