Skip to content

Commit

Permalink
Update to new libp2p API
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Mar 11, 2025
1 parent 83978a4 commit 8a83fbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions substrate/client/network/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,10 @@ impl From<void::Void> for BehaviourOut {
void::unreachable(e)
}
}

// Infallible instances can never actually be created.
impl From<std::convert::Infallible> for BehaviourOut {
fn from(_: std::convert::Infallible) -> Self {
unreachable!()
}
}
10 changes: 5 additions & 5 deletions substrate/client/network/src/request_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub enum Event {
/// This event is generated for statistics purposes.
RequestFinished {
/// Peer that we send a request to.
peer: PeerId,
peer: Option<PeerId>,
/// Name of the protocol in question.
protocol: ProtocolName,
/// Duration the request took.
Expand Down Expand Up @@ -469,7 +469,7 @@ impl RequestResponsesBehaviour {
Self::send_request_inner(
behaviour,
&mut self.pending_requests,
target,
target.into(),
protocol_name,
request,
fallback_request,
Expand Down Expand Up @@ -854,7 +854,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
};

let out = Event::RequestFinished {
peer,
peer: Some(peer),
protocol: protocol.clone(),
duration: started.elapsed(),
result: delivered,
Expand Down Expand Up @@ -883,8 +883,8 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
// Try using the fallback request if the protocol was not
// supported.
if matches!(error, OutboundFailure::UnsupportedProtocols) {
if let Some((fallback_request, fallback_protocol)) =
fallback_request
if let (Some((fallback_request, fallback_protocol)), Some(peer)) =
(fallback_request, peer)
{
log::trace!(
target: "sub-libp2p",
Expand Down

0 comments on commit 8a83fbb

Please sign in to comment.