Skip to content

Commit

Permalink
protocols/: Remove passing default variant to WithPeerId::condition (
Browse files Browse the repository at this point in the history
  • Loading branch information
K0UR05H authored Aug 10, 2022
1 parent 3da8b42 commit 1012579
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 35 deletions.
12 changes: 4 additions & 8 deletions protocols/floodsub/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use fnv::FnvHashSet;
use libp2p_core::{connection::ConnectionId, PeerId};
use libp2p_core::{ConnectedPoint, Multiaddr};
use libp2p_swarm::{
dial_opts::{self, DialOpts},
NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, OneShotHandler, PollParameters,
dial_opts::DialOpts, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, OneShotHandler,
PollParameters,
};
use log::warn;
use smallvec::SmallVec;
Expand Down Expand Up @@ -109,9 +109,7 @@ impl Floodsub {
if self.target_peers.insert(peer_id) {
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(peer_id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
opts: DialOpts::peer_id(peer_id).build(),
handler,
});
}
Expand Down Expand Up @@ -343,9 +341,7 @@ impl NetworkBehaviour for Floodsub {
if self.target_peers.contains(id) {
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(*id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
opts: DialOpts::peer_id(*id).build(),
handler,
});
}
Expand Down
12 changes: 4 additions & 8 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ use libp2p_core::{
multiaddr::Protocol::Ip6, ConnectedPoint, Multiaddr, PeerId,
};
use libp2p_swarm::{
dial_opts::{self, DialOpts},
IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
dial_opts::DialOpts, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction,
NotifyHandler, PollParameters,
};
use wasm_timer::Instant;

Expand Down Expand Up @@ -1143,9 +1143,7 @@ where
debug!("Connecting to explicit peer {:?}", peer_id);
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(*peer_id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
opts: DialOpts::peer_id(*peer_id).build(),
handler,
});
}
Expand Down Expand Up @@ -1644,9 +1642,7 @@ where
// dial peer
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(peer_id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
opts: DialOpts::peer_id(peer_id).build(),
handler,
});
}
Expand Down
10 changes: 4 additions & 6 deletions protocols/identify/src/identify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ use libp2p_core::{
Multiaddr, PeerId, PublicKey,
};
use libp2p_swarm::{
dial_opts::{self, DialOpts},
AddressScore, ConnectionHandler, ConnectionHandlerUpgrErr, DialError, IntoConnectionHandler,
NegotiatedSubstream, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
dial_opts::DialOpts, AddressScore, ConnectionHandler, ConnectionHandlerUpgrErr, DialError,
IntoConnectionHandler, NegotiatedSubstream, NetworkBehaviour, NetworkBehaviourAction,
NotifyHandler, PollParameters,
};
use lru::LruCache;
use std::{
Expand Down Expand Up @@ -196,9 +196,7 @@ impl Identify {
if self.pending_push.insert(p) && !self.connected.contains_key(&p) {
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(p)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
opts: DialOpts::peer_id(p).build(),
handler,
});
}
Expand Down
9 changes: 2 additions & 7 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,7 @@ where
kbucket::InsertResult::Pending { disconnected } => {
let handler = self.new_handler();
self.queued_events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(disconnected.into_preimage())
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
opts: DialOpts::peer_id(disconnected.into_preimage()).build(),
handler,
});
RoutingUpdate::Pending
Expand Down Expand Up @@ -1162,7 +1160,6 @@ where
let handler = self.new_handler();
self.queued_events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(disconnected.into_preimage())
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
handler,
})
Expand Down Expand Up @@ -2342,9 +2339,7 @@ where
query.inner.pending_rpcs.push((peer_id, event));
let handler = self.new_handler();
self.queued_events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(peer_id)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
opts: DialOpts::peer_id(peer_id).build(),
handler,
});
}
Expand Down
9 changes: 3 additions & 6 deletions protocols/request-response/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ use futures::channel::oneshot;
use handler::{RequestProtocol, RequestResponseHandler, RequestResponseHandlerEvent};
use libp2p_core::{connection::ConnectionId, ConnectedPoint, Multiaddr, PeerId};
use libp2p_swarm::{
dial_opts::{self, DialOpts},
DialError, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler,
PollParameters,
dial_opts::DialOpts, DialError, IntoConnectionHandler, NetworkBehaviour,
NetworkBehaviourAction, NotifyHandler, PollParameters,
};
use smallvec::SmallVec;
use std::{
Expand Down Expand Up @@ -385,9 +384,7 @@ where
if let Some(request) = self.try_send_request(peer, request) {
let handler = self.new_handler();
self.pending_events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(*peer)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
opts: DialOpts::peer_id(*peer).build(),
handler,
});
self.pending_outbound_requests
Expand Down

0 comments on commit 1012579

Please sign in to comment.