protocols/: Remove passing default variant to WithPeerId::condition (#2802)

This commit is contained in:
Kourosh
2022-08-10 12:20:24 +04:30
committed by GitHub
parent 3da8b423c2
commit 1012579d77
5 changed files with 17 additions and 35 deletions

View File

@ -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;
@ -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,
});
}
@ -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,
});
}

View File

@ -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;
@ -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,
});
}
@ -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,
});
}

View File

@ -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::{
@ -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,
});
}

View File

@ -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
@ -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,
})
@ -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,
});
}

View File

@ -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::{
@ -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