diff --git a/rust/Cargo.toml b/rust/Cargo.toml index bae0d5e..d78840b 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libp2p = { version = "0.39.1", default-features = false, features = ["dns-async-std", "noise", "plaintext", "tcp-async-io", "yamux"] } +libp2p = { version = "0.40.0-rc.1", default-features = false, features = ["dns-async-std", "noise", "plaintext", "tcp-async-io", "yamux"] } futures_codec = "0.4" futures = "0.3.1" async-std = { version = "1.6.2", features = ["attributes"] } diff --git a/rust/src/behaviour.rs b/rust/src/behaviour.rs index 8043b3e..a51d60b 100644 --- a/rust/src/behaviour.rs +++ b/rust/src/behaviour.rs @@ -5,7 +5,7 @@ use libp2p::{ ConnectedPoint, }, swarm::{ - IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, + DialError, IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters, ProtocolsHandler, }, Multiaddr, PeerId, @@ -18,7 +18,12 @@ use std::time::Duration; #[derive(Default)] pub struct Perf { connected_peers: Vec<(PeerId, Direction)>, - outbox: Vec::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent, ::OutEvent>> + outbox: Vec< + NetworkBehaviourAction< + ::OutEvent, + ::ProtocolsHandler, + >, + >, } enum Direction { @@ -58,6 +63,7 @@ impl NetworkBehaviour for Perf { peer_id: &PeerId, _: &ConnectionId, connected_point: &ConnectedPoint, + _failed_addresses: Option<&Vec>, ) { let direction = match connected_point { ConnectedPoint::Dialer { .. } => Direction::Outgoing, @@ -67,7 +73,14 @@ impl NetworkBehaviour for Perf { self.connected_peers.push((peer_id.clone(), direction)); } - fn inject_connection_closed(&mut self, _: &PeerId, _: &ConnectionId, _: &ConnectedPoint) {} + fn inject_connection_closed( + &mut self, + _: &PeerId, + _: &ConnectionId, + _: &ConnectedPoint, + _handler: PerfHandler, + ) { + } fn inject_event( &mut self, @@ -82,16 +95,12 @@ impl NetworkBehaviour for Perf { } } - fn inject_addr_reach_failure( + fn inject_dial_failure( &mut self, - _peer_id: Option<&PeerId>, - _addr: &Multiaddr, - error: &dyn error::Error, + _peer_id: Option, + _handler: PerfHandler, + _error: &DialError, ) { - panic!("inject addr reach failure: {:?}", error); - } - - fn inject_dial_failure(&mut self, _peer_id: &PeerId) { panic!("inject dial failure"); } @@ -109,8 +118,11 @@ impl NetworkBehaviour for Perf { panic!("listener closed {:?}", reason); } - fn poll(&mut self, _cx: &mut Context, _params: &mut impl PollParameters) - -> Poll::Handler as ProtocolsHandler>::InEvent, Self::OutEvent>>{ + fn poll( + &mut self, + _cx: &mut Context, + _params: &mut impl PollParameters, + ) -> Poll> { if let Some(action) = self.outbox.pop() { return Poll::Ready(action); } diff --git a/rust/src/handler.rs b/rust/src/handler.rs index 1fbe912..41a3f39 100644 --- a/rust/src/handler.rs +++ b/rust/src/handler.rs @@ -211,6 +211,7 @@ pub enum PerfHandlerIn { StartPerf, } +#[derive(Debug)] pub enum PerfHandlerOut { PerfRunDone(Duration, usize), }