Skip to content

Commit a269e9d

Browse files
Revert "Allow each NetworkBehaviour to have their own ConnectionDenied reason"
This reverts commit 19348e9.
1 parent 527eeda commit a269e9d

File tree

32 files changed

+145
-296
lines changed

32 files changed

+145
-296
lines changed

examples/file-sharing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ mod network {
408408
&mut self,
409409
event: SwarmEvent<
410410
ComposedEvent,
411-
ComposedBehaviourConnectionDenied,
412411
EitherError<ConnectionHandlerUpgrErr<io::Error>, io::Error>,
413412
>,
414413
) {

misc/metrics/src/identify.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,8 @@ impl super::Recorder<libp2p_identify::Event> for Metrics {
193193
}
194194
}
195195

196-
impl<TBvEv, TReason, THandleErr>
197-
super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, TReason, THandleErr>> for Metrics
198-
{
199-
fn record(&self, event: &libp2p_swarm::SwarmEvent<TBvEv, TReason, THandleErr>) {
196+
impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleErr>> for Metrics {
197+
fn record(&self, event: &libp2p_swarm::SwarmEvent<TBvEv, THandleErr>) {
200198
if let libp2p_swarm::SwarmEvent::ConnectionClosed {
201199
peer_id,
202200
num_established,

misc/metrics/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,8 @@ impl Recorder<libp2p_relay::v2::relay::Event> for Metrics {
142142
}
143143
}
144144

145-
impl<TBvEv, TReason, THandleErr> Recorder<libp2p_swarm::SwarmEvent<TBvEv, TReason, THandleErr>>
146-
for Metrics
147-
{
148-
fn record(&self, event: &libp2p_swarm::SwarmEvent<TBvEv, TReason, THandleErr>) {
145+
impl<TBvEv, THandleErr> Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleErr>> for Metrics {
146+
fn record(&self, event: &libp2p_swarm::SwarmEvent<TBvEv, THandleErr>) {
149147
self.swarm.record(event);
150148

151149
#[cfg(feature = "identify")]

misc/metrics/src/swarm.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ impl Metrics {
139139
}
140140
}
141141

142-
impl<TBvEv, TReason, THandleErr>
143-
super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, TReason, THandleErr>> for Metrics
144-
{
145-
fn record(&self, event: &libp2p_swarm::SwarmEvent<TBvEv, TReason, THandleErr>) {
142+
impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleErr>> for Metrics {
143+
fn record(&self, event: &libp2p_swarm::SwarmEvent<TBvEv, THandleErr>) {
146144
match event {
147145
libp2p_swarm::SwarmEvent::Behaviour(_) => {}
148146
libp2p_swarm::SwarmEvent::ConnectionEstablished { endpoint, .. } => {
@@ -271,7 +269,6 @@ impl<TBvEv, TReason, THandleErr>
271269
libp2p_swarm::SwarmEvent::Dialing(_) => {
272270
self.dial_attempt.inc();
273271
}
274-
libp2p_swarm::SwarmEvent::ConnectionDenied { .. } => {}
275272
}
276273
}
277274
}

protocols/autonat/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ libp2p-request-response = { version = "0.23.0", path = "../request-response" }
2424
log = "0.4"
2525
rand = "0.8"
2626
prost = "0.11"
27-
void = "1.0.2"
2827

2928
[dev-dependencies]
3029
async-std = { version = "1.10", features = ["attributes"] }

protocols/autonat/src/behaviour.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use libp2p_request_response::{
3535
ProtocolSupport, RequestId, RequestResponse, RequestResponseConfig, RequestResponseEvent,
3636
RequestResponseMessage, ResponseChannel,
3737
};
38-
use libp2p_swarm::behaviour::THandlerInEvent;
38+
use libp2p_swarm::behaviour::{ConnectionDenied, THandlerInEvent};
3939
use libp2p_swarm::{
4040
behaviour::{
4141
AddressChange, ConnectionClosed, ConnectionEstablished, DialFailure, ExpiredExternalAddr,
@@ -50,7 +50,6 @@ use std::{
5050
task::{Context, Poll},
5151
time::Duration,
5252
};
53-
use void::Void;
5453

5554
/// Config for the [`Behaviour`].
5655
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -411,7 +410,6 @@ impl Behaviour {
411410

412411
impl NetworkBehaviour for Behaviour {
413412
type ConnectionHandler = <RequestResponse<AutoNatCodec> as NetworkBehaviour>::ConnectionHandler;
414-
type ConnectionDenied = Void;
415413
type OutEvent = Event;
416414

417415
fn poll(&mut self, cx: &mut Context<'_>, params: &mut impl PollParameters) -> Poll<Action> {
@@ -463,7 +461,7 @@ impl NetworkBehaviour for Behaviour {
463461
&mut self,
464462
peer: &PeerId,
465463
connected_point: &ConnectedPoint,
466-
) -> Result<Self::ConnectionHandler, Self::ConnectionDenied> {
464+
) -> Result<Self::ConnectionHandler, ConnectionDenied> {
467465
self.inner.new_handler(peer, connected_point)
468466
}
469467

protocols/dcutr/src/behaviour.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ use libp2p_core::connection::{ConnectedPoint, ConnectionId};
2727
use libp2p_core::multiaddr::Protocol;
2828
use libp2p_core::{Multiaddr, PeerId};
2929
use libp2p_swarm::behaviour::{
30-
ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm, THandlerInEvent,
30+
ConnectionClosed, ConnectionDenied, ConnectionEstablished, DialFailure, FromSwarm,
31+
THandlerInEvent,
3132
};
3233
use libp2p_swarm::dial_opts::{self, DialOpts};
3334
use libp2p_swarm::{
@@ -38,7 +39,6 @@ use std::collections::hash_map::Entry;
3839
use std::collections::{HashMap, HashSet, VecDeque};
3940
use std::task::{Context, Poll};
4041
use thiserror::Error;
41-
use void::Void;
4242

4343
const MAX_NUMBER_OF_UPGRADE_ATTEMPTS: u8 = 3;
4444

@@ -210,14 +210,13 @@ impl Behaviour {
210210

211211
impl NetworkBehaviour for Behaviour {
212212
type ConnectionHandler = Handler;
213-
type ConnectionDenied = Void;
214213
type OutEvent = Event;
215214

216215
fn new_handler(
217216
&mut self,
218217
peer: &PeerId,
219218
connected_point: &ConnectedPoint,
220-
) -> Result<Self::ConnectionHandler, Self::ConnectionDenied> {
219+
) -> Result<Self::ConnectionHandler, ConnectionDenied> {
221220
match (
222221
self.awaiting_direct_inbound_connections.entry(*peer),
223222
self.awaiting_direct_outbound_connections.entry(*peer),

protocols/floodsub/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ prost = "0.11"
2121
rand = "0.8"
2222
smallvec = "1.6.1"
2323
thiserror = "1.0.37"
24-
void = "1.0.2"
2524

2625
[build-dependencies]
2726
prost-build = "0.11"

protocols/floodsub/src/layer.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ use crate::FloodsubConfig;
2727
use cuckoofilter::{CuckooError, CuckooFilter};
2828
use fnv::FnvHashSet;
2929
use libp2p_core::{connection::ConnectionId, ConnectedPoint, PeerId};
30-
use libp2p_swarm::behaviour::THandlerInEvent;
3130
use libp2p_swarm::behaviour::{ConnectionClosed, ConnectionEstablished, FromSwarm};
31+
use libp2p_swarm::behaviour::{ConnectionDenied, THandlerInEvent};
3232
use libp2p_swarm::ConnectionHandler;
3333
use libp2p_swarm::{
3434
dial_opts::DialOpts, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, OneShotHandler,
@@ -39,7 +39,6 @@ use smallvec::SmallVec;
3939
use std::collections::hash_map::{DefaultHasher, HashMap};
4040
use std::task::{Context, Poll};
4141
use std::{collections::VecDeque, iter};
42-
use void::Void;
4342

4443
/// Network behaviour that handles the floodsub protocol.
4544
pub struct Floodsub {
@@ -335,14 +334,13 @@ impl Floodsub {
335334

336335
impl NetworkBehaviour for Floodsub {
337336
type ConnectionHandler = OneShotHandler<FloodsubProtocol, FloodsubRpc, InnerMessage>;
338-
type ConnectionDenied = Void;
339337
type OutEvent = FloodsubEvent;
340338

341339
fn new_handler(
342340
&mut self,
343341
_: &PeerId,
344342
_: &ConnectedPoint,
345-
) -> Result<Self::ConnectionHandler, Self::ConnectionDenied> {
343+
) -> Result<Self::ConnectionHandler, ConnectionDenied> {
346344
Ok(Default::default())
347345
}
348346

protocols/gossipsub/Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
1111
categories = ["network-programming", "asynchronous"]
1212

1313
[dependencies]
14-
asynchronous-codec = "0.6"
15-
base64 = "0.13.0"
16-
byteorder = "1.3.4"
14+
libp2p-swarm = { version = "0.41.0", path = "../../swarm" }
15+
libp2p-core = { version = "0.38.0", path = "../../core" }
1716
bytes = "1.0"
17+
byteorder = "1.3.4"
1818
fnv = "1.0.7"
1919
futures = "0.3.5"
20-
hex_fmt = "0.3.0"
21-
instant = "0.1.11"
22-
libp2p-core = { version = "0.38.0", path = "../../core" }
23-
libp2p-swarm = { version = "0.41.0", path = "../../swarm" }
20+
rand = "0.8"
21+
asynchronous-codec = "0.6"
22+
unsigned-varint = { version = "0.7.0", features = ["asynchronous_codec"] }
2423
log = "0.4.11"
25-
prometheus-client = "0.18.0" # Metrics dependencies
24+
sha2 = "0.10.0"
25+
base64 = "0.13.0"
26+
smallvec = "1.6.1"
2627
prost = "0.11"
2728
prost-codec = { version = "0.3", path = "../../misc/prost-codec" }
28-
rand = "0.8"
29+
hex_fmt = "0.3.0"
2930
regex = "1.5.5"
3031
serde = { version = "1", optional = true, features = ["derive"] }
31-
sha2 = "0.10.0"
32-
smallvec = "1.6.1"
3332
thiserror = "1.0"
34-
unsigned-varint = { version = "0.7.0", features = ["asynchronous_codec"] }
35-
void = "1.0.2"
3633
wasm-timer = "0.2.5"
34+
instant = "0.1.11"
35+
# Metrics dependencies
36+
prometheus-client = "0.18.0"
3737

3838
[dev-dependencies]
3939
async-std = "1.6.3"

0 commit comments

Comments
 (0)