Skip to content

Commit

Permalink
protocols/identify: Update to latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Nov 8, 2021
1 parent ad083e9 commit eea9e12
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions protocols/identify/src/identify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ use libp2p_core::{
ConnectedPoint, Multiaddr, PeerId, PublicKey,
};
use libp2p_swarm::{
AddressScore, DialError, DialPeerCondition, IntoProtocolsHandler, NegotiatedSubstream,
NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters, ProtocolsHandler,
dial_opts::{self, DialOpts},
AddressScore, DialError, IntoProtocolsHandler, NegotiatedSubstream, NetworkBehaviour,
NetworkBehaviourAction, NotifyHandler, PollParameters, ProtocolsHandler,
ProtocolsHandlerUpgrErr,
};
use lru::LruCache;
Expand Down Expand Up @@ -198,9 +199,10 @@ impl Identify {
if self.pending_push.insert(p) {
if !self.connected.contains_key(&p) {
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::DialPeer {
peer_id: p,
condition: DialPeerCondition::Disconnected,
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(p)
.condition(dial_opts::PeerCondition::Disconnected)
.build(),
handler,
});
}
Expand Down Expand Up @@ -561,7 +563,9 @@ mod tests {
}
}
});
swarm2.dial_addr(listen_addr).unwrap();
swarm2
.dial(DialOpts::unknown_peer_id().address(listen_addr).build())
.unwrap();

// nb. Either swarm may receive the `Identified` event first, upon which
// it will permit the connection to be closed, as defined by
Expand Down Expand Up @@ -641,7 +645,9 @@ mod tests {
}
});

Swarm::dial_addr(&mut swarm2, listen_addr).unwrap();
swarm2
.dial(DialOpts::unknown_peer_id().address(listen_addr).build())
.unwrap();

async_std::task::block_on(async move {
loop {
Expand Down Expand Up @@ -728,7 +734,9 @@ mod tests {
}
});

swarm2.dial_addr(listen_addr).unwrap();
swarm2
.dial(DialOpts::unknown_peer_id().address(listen_addr).build())
.unwrap();

// wait until we identified
async_std::task::block_on(async {
Expand All @@ -744,7 +752,9 @@ mod tests {
swarm2.disconnect_peer_id(swarm1_peer_id).unwrap();

// we should still be able to dial now!
swarm2.dial(&swarm1_peer_id).unwrap();
swarm2
.dial(DialOpts::peer_id(swarm1_peer_id).build())
.unwrap();

let connected_peer = async_std::task::block_on(async {
loop {
Expand Down

0 comments on commit eea9e12

Please sign in to comment.