From 04d658ad7d1e08b39fe7a6d990dcb698dbb63ddb Mon Sep 17 00:00:00 2001 From: k0ur0x Date: Mon, 8 Aug 2022 15:00:34 +0430 Subject: [PATCH 1/3] Remove `inject_connected` / `inject_disconnected` from docs --- protocols/gossipsub/src/behaviour.rs | 2 +- swarm/src/behaviour.rs | 2 +- swarm/src/lib.rs | 7 +------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index 3ec0b117d58..7e21781ad6f 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -3339,7 +3339,7 @@ where )); } else if let Some(conn) = self.connected_peers.get_mut(&propagation_source) { // Only change the value if the old value is Floodsub (the default set in - // inject_connected). All other PeerKind changes are ignored. + // inject_connection_established). All other PeerKind changes are ignored. debug!( "New peer type found: {} for peer: {}", kind, propagation_source diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 7ab54c73c05..2c9865398e5 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -230,7 +230,7 @@ pub trait NetworkBehaviour: 'static { /// Informs the behaviour about an event generated by the handler dedicated to the peer identified by `peer_id`. /// for the behaviour. /// - /// The `peer_id` is guaranteed to be in a connected state. In other words, `inject_connected` + /// The `peer_id` is guaranteed to be in a connected state. In other words, `inject_connection_established` /// has previously been called with this `PeerId`. fn inject_event( &mut self, diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index f32c2df56bf..2021efa67cf 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1701,13 +1701,11 @@ mod tests { /// after which one peer bans the other. /// /// The test expects both behaviours to be notified via pairs of - /// inject_connected / inject_disconnected as well as /// inject_connection_established / inject_connection_closed calls /// while unbanned. /// /// While the ban is in effect, further dials occur. For these connections no - /// `inject_connected`, `inject_connection_established`, `inject_disconnected`, - /// `inject_connection_closed` calls should be registered. + /// `inject_connection_established`, `inject_connection_closed` calls should be registered. #[test] fn test_connect_disconnect_ban() { // Since the test does not try to open any substreams, we can @@ -1827,7 +1825,6 @@ mod tests { /// after which one peer disconnects the other using [`Swarm::disconnect_peer_id`]. /// /// The test expects both behaviours to be notified via pairs of - /// inject_connected / inject_disconnected as well as /// inject_connection_established / inject_connection_closed calls. #[test] fn test_swarm_disconnect() { @@ -1896,7 +1893,6 @@ mod tests { /// using [`NetworkBehaviourAction::CloseConnection`] returned by a [`NetworkBehaviour`]. /// /// The test expects both behaviours to be notified via pairs of - /// inject_connected / inject_disconnected as well as /// inject_connection_established / inject_connection_closed calls. #[test] fn test_behaviour_disconnect_all() { @@ -1967,7 +1963,6 @@ mod tests { /// using [`NetworkBehaviourAction::CloseConnection`] returned by a [`NetworkBehaviour`]. /// /// The test expects both behaviours to be notified via pairs of - /// inject_connected / inject_disconnected as well as /// inject_connection_established / inject_connection_closed calls. #[test] fn test_behaviour_disconnect_one() { From fd058aef6972bd03af84fd99c75e5c5b23c5ba7d Mon Sep 17 00:00:00 2001 From: k0ur0x Date: Tue, 9 Aug 2022 07:19:04 +0430 Subject: [PATCH 2/3] Link to methods --- swarm/src/behaviour.rs | 9 ++++----- swarm/src/lib.rs | 11 ++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 2c9865398e5..5070305cc2e 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -204,9 +204,8 @@ pub trait NetworkBehaviour: 'static { /// Informs the behaviour about a closed connection to a peer. /// - /// A call to this method is always paired with an earlier call to - /// `inject_connection_established` with the same peer ID, connection ID and - /// endpoint. + /// A call to this method is always paired with an earlier call to [`NetworkBehaviour::inject_connection_established`] with + /// the same peer ID, connection ID and endpoint. fn inject_connection_closed( &mut self, _: &PeerId, @@ -230,8 +229,8 @@ pub trait NetworkBehaviour: 'static { /// Informs the behaviour about an event generated by the handler dedicated to the peer identified by `peer_id`. /// for the behaviour. /// - /// The `peer_id` is guaranteed to be in a connected state. In other words, `inject_connection_established` - /// has previously been called with this `PeerId`. + /// The `peer_id` is guaranteed to be in a connected state. In other words, + /// [`NetworkBehaviour::inject_connection_established`] has previously been called with this `PeerId`. fn inject_event( &mut self, peer_id: PeerId, diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 2021efa67cf..21664740e11 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1701,11 +1701,12 @@ mod tests { /// after which one peer bans the other. /// /// The test expects both behaviours to be notified via pairs of - /// inject_connection_established / inject_connection_closed calls + /// [`NetworkBehaviour::inject_connection_established`] / [`NetworkBehaviour::inject_connection_closed`] calls /// while unbanned. /// /// While the ban is in effect, further dials occur. For these connections no - /// `inject_connection_established`, `inject_connection_closed` calls should be registered. + /// [`NetworkBehaviour::inject_connection_established`], [`NetworkBehaviour::inject_connection_closed`] calls + /// should be registered. #[test] fn test_connect_disconnect_ban() { // Since the test does not try to open any substreams, we can @@ -1825,7 +1826,7 @@ mod tests { /// after which one peer disconnects the other using [`Swarm::disconnect_peer_id`]. /// /// The test expects both behaviours to be notified via pairs of - /// inject_connection_established / inject_connection_closed calls. + /// [`NetworkBehaviour::inject_connection_established`] / [`NetworkBehaviour::inject_connection_closed`] calls. #[test] fn test_swarm_disconnect() { // Since the test does not try to open any substreams, we can @@ -1893,7 +1894,7 @@ mod tests { /// using [`NetworkBehaviourAction::CloseConnection`] returned by a [`NetworkBehaviour`]. /// /// The test expects both behaviours to be notified via pairs of - /// inject_connection_established / inject_connection_closed calls. + /// [`NetworkBehaviour::inject_connection_established`] / [`NetworkBehaviour::inject_connection_closed`] calls. #[test] fn test_behaviour_disconnect_all() { // Since the test does not try to open any substreams, we can @@ -1963,7 +1964,7 @@ mod tests { /// using [`NetworkBehaviourAction::CloseConnection`] returned by a [`NetworkBehaviour`]. /// /// The test expects both behaviours to be notified via pairs of - /// inject_connection_established / inject_connection_closed calls. + /// [`NetworkBehaviour::inject_connection_established`] / [`NetworkBehaviour::inject_connection_closed`] calls. #[test] fn test_behaviour_disconnect_one() { // Since the test does not try to open any substreams, we can From 96f68a97b71645be48c6a1093cc2c6a00ba45b4b Mon Sep 17 00:00:00 2001 From: k0ur0x Date: Wed, 10 Aug 2022 11:34:37 +0430 Subject: [PATCH 3/3] Wrap lines --- swarm/src/behaviour.rs | 4 ++-- swarm/src/lib.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 5070305cc2e..d6802c086a8 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -204,8 +204,8 @@ pub trait NetworkBehaviour: 'static { /// Informs the behaviour about a closed connection to a peer. /// - /// A call to this method is always paired with an earlier call to [`NetworkBehaviour::inject_connection_established`] with - /// the same peer ID, connection ID and endpoint. + /// A call to this method is always paired with an earlier call to + /// [`NetworkBehaviour::inject_connection_established`] with the same peer ID, connection ID and endpoint. fn inject_connection_closed( &mut self, _: &PeerId, diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 21664740e11..74de015a858 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1701,12 +1701,12 @@ mod tests { /// after which one peer bans the other. /// /// The test expects both behaviours to be notified via pairs of - /// [`NetworkBehaviour::inject_connection_established`] / [`NetworkBehaviour::inject_connection_closed`] calls - /// while unbanned. + /// [`NetworkBehaviour::inject_connection_established`] / [`NetworkBehaviour::inject_connection_closed`] + /// calls while unbanned. /// /// While the ban is in effect, further dials occur. For these connections no - /// [`NetworkBehaviour::inject_connection_established`], [`NetworkBehaviour::inject_connection_closed`] calls - /// should be registered. + /// [`NetworkBehaviour::inject_connection_established`], [`NetworkBehaviour::inject_connection_closed`] + /// calls should be registered. #[test] fn test_connect_disconnect_ban() { // Since the test does not try to open any substreams, we can