Skip to content

Commit 1012579

Browse files
authored
protocols/: Remove passing default variant to WithPeerId::condition (#2802)
1 parent 3da8b42 commit 1012579

File tree

5 files changed

+17
-35
lines changed

5 files changed

+17
-35
lines changed

protocols/floodsub/src/layer.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use fnv::FnvHashSet;
2929
use libp2p_core::{connection::ConnectionId, PeerId};
3030
use libp2p_core::{ConnectedPoint, Multiaddr};
3131
use libp2p_swarm::{
32-
dial_opts::{self, DialOpts},
33-
NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, OneShotHandler, PollParameters,
32+
dial_opts::DialOpts, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, OneShotHandler,
33+
PollParameters,
3434
};
3535
use log::warn;
3636
use smallvec::SmallVec;
@@ -109,9 +109,7 @@ impl Floodsub {
109109
if self.target_peers.insert(peer_id) {
110110
let handler = self.new_handler();
111111
self.events.push_back(NetworkBehaviourAction::Dial {
112-
opts: DialOpts::peer_id(peer_id)
113-
.condition(dial_opts::PeerCondition::Disconnected)
114-
.build(),
112+
opts: DialOpts::peer_id(peer_id).build(),
115113
handler,
116114
});
117115
}
@@ -343,9 +341,7 @@ impl NetworkBehaviour for Floodsub {
343341
if self.target_peers.contains(id) {
344342
let handler = self.new_handler();
345343
self.events.push_back(NetworkBehaviourAction::Dial {
346-
opts: DialOpts::peer_id(*id)
347-
.condition(dial_opts::PeerCondition::Disconnected)
348-
.build(),
344+
opts: DialOpts::peer_id(*id).build(),
349345
handler,
350346
});
351347
}

protocols/gossipsub/src/behaviour.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ use libp2p_core::{
4141
multiaddr::Protocol::Ip6, ConnectedPoint, Multiaddr, PeerId,
4242
};
4343
use libp2p_swarm::{
44-
dial_opts::{self, DialOpts},
45-
IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
44+
dial_opts::DialOpts, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction,
45+
NotifyHandler, PollParameters,
4646
};
4747
use wasm_timer::Instant;
4848

@@ -1143,9 +1143,7 @@ where
11431143
debug!("Connecting to explicit peer {:?}", peer_id);
11441144
let handler = self.new_handler();
11451145
self.events.push_back(NetworkBehaviourAction::Dial {
1146-
opts: DialOpts::peer_id(*peer_id)
1147-
.condition(dial_opts::PeerCondition::Disconnected)
1148-
.build(),
1146+
opts: DialOpts::peer_id(*peer_id).build(),
11491147
handler,
11501148
});
11511149
}
@@ -1644,9 +1642,7 @@ where
16441642
// dial peer
16451643
let handler = self.new_handler();
16461644
self.events.push_back(NetworkBehaviourAction::Dial {
1647-
opts: DialOpts::peer_id(peer_id)
1648-
.condition(dial_opts::PeerCondition::Disconnected)
1649-
.build(),
1645+
opts: DialOpts::peer_id(peer_id).build(),
16501646
handler,
16511647
});
16521648
}

protocols/identify/src/identify.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ use libp2p_core::{
2626
Multiaddr, PeerId, PublicKey,
2727
};
2828
use libp2p_swarm::{
29-
dial_opts::{self, DialOpts},
30-
AddressScore, ConnectionHandler, ConnectionHandlerUpgrErr, DialError, IntoConnectionHandler,
31-
NegotiatedSubstream, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
29+
dial_opts::DialOpts, AddressScore, ConnectionHandler, ConnectionHandlerUpgrErr, DialError,
30+
IntoConnectionHandler, NegotiatedSubstream, NetworkBehaviour, NetworkBehaviourAction,
31+
NotifyHandler, PollParameters,
3232
};
3333
use lru::LruCache;
3434
use std::{
@@ -196,9 +196,7 @@ impl Identify {
196196
if self.pending_push.insert(p) && !self.connected.contains_key(&p) {
197197
let handler = self.new_handler();
198198
self.events.push_back(NetworkBehaviourAction::Dial {
199-
opts: DialOpts::peer_id(p)
200-
.condition(dial_opts::PeerCondition::Disconnected)
201-
.build(),
199+
opts: DialOpts::peer_id(p).build(),
202200
handler,
203201
});
204202
}

protocols/kad/src/behaviour.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,7 @@ where
565565
kbucket::InsertResult::Pending { disconnected } => {
566566
let handler = self.new_handler();
567567
self.queued_events.push_back(NetworkBehaviourAction::Dial {
568-
opts: DialOpts::peer_id(disconnected.into_preimage())
569-
.condition(dial_opts::PeerCondition::Disconnected)
570-
.build(),
568+
opts: DialOpts::peer_id(disconnected.into_preimage()).build(),
571569
handler,
572570
});
573571
RoutingUpdate::Pending
@@ -1162,7 +1160,6 @@ where
11621160
let handler = self.new_handler();
11631161
self.queued_events.push_back(NetworkBehaviourAction::Dial {
11641162
opts: DialOpts::peer_id(disconnected.into_preimage())
1165-
.condition(dial_opts::PeerCondition::Disconnected)
11661163
.build(),
11671164
handler,
11681165
})
@@ -2342,9 +2339,7 @@ where
23422339
query.inner.pending_rpcs.push((peer_id, event));
23432340
let handler = self.new_handler();
23442341
self.queued_events.push_back(NetworkBehaviourAction::Dial {
2345-
opts: DialOpts::peer_id(peer_id)
2346-
.condition(dial_opts::PeerCondition::Disconnected)
2347-
.build(),
2342+
opts: DialOpts::peer_id(peer_id).build(),
23482343
handler,
23492344
});
23502345
}

protocols/request-response/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ use futures::channel::oneshot;
6666
use handler::{RequestProtocol, RequestResponseHandler, RequestResponseHandlerEvent};
6767
use libp2p_core::{connection::ConnectionId, ConnectedPoint, Multiaddr, PeerId};
6868
use libp2p_swarm::{
69-
dial_opts::{self, DialOpts},
70-
DialError, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler,
71-
PollParameters,
69+
dial_opts::DialOpts, DialError, IntoConnectionHandler, NetworkBehaviour,
70+
NetworkBehaviourAction, NotifyHandler, PollParameters,
7271
};
7372
use smallvec::SmallVec;
7473
use std::{
@@ -385,9 +384,7 @@ where
385384
if let Some(request) = self.try_send_request(peer, request) {
386385
let handler = self.new_handler();
387386
self.pending_events.push_back(NetworkBehaviourAction::Dial {
388-
opts: DialOpts::peer_id(*peer)
389-
.condition(dial_opts::PeerCondition::Disconnected)
390-
.build(),
387+
opts: DialOpts::peer_id(*peer).build(),
391388
handler,
392389
});
393390
self.pending_outbound_requests

0 commit comments

Comments
 (0)