mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 10:01:25 +00:00
Make sure inject_dial_failure is called (#1549)
* Make sure inject_dial_failure is called * Update CHANGELOG * Make libp2p-kad tests pass * Fix again * Update swarm/src/lib.rs Co-Authored-By: Toralf Wittner <tw@dtex.org> * Revert "Fix again" This reverts commit 80c0d3d908aff282d492f213d2ce34d12489167d. * Bump versions and CHANGELOG * Oops, didn't bump libp2p-swarm in libp2p Co-authored-by: Toralf Wittner <tw@dtex.org>
This commit is contained in:
@ -403,6 +403,12 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
return Err(error)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::debug!(
|
||||
"New dialing attempt to disconnected peer {:?} failed: no address.",
|
||||
peer_id
|
||||
);
|
||||
me.behaviour.inject_dial_failure(&peer_id);
|
||||
}
|
||||
Ok(false)
|
||||
},
|
||||
@ -419,6 +425,12 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
return Err(error)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::debug!(
|
||||
"New dialing attempt to disconnected peer {:?} failed: no address.",
|
||||
peer_id
|
||||
);
|
||||
me.behaviour.inject_dial_failure(&peer_id);
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
@ -427,6 +439,7 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
Ok(false)
|
||||
},
|
||||
Peer::Local => {
|
||||
me.behaviour.inject_dial_failure(&peer_id);
|
||||
Err(ConnectionLimit { current: 0, limit: 0 })
|
||||
}
|
||||
}
|
||||
@ -701,34 +714,25 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
if this.banned_peers.contains(&peer_id) {
|
||||
this.behaviour.inject_dial_failure(&peer_id);
|
||||
} else {
|
||||
let result = match condition {
|
||||
let condition_matched = match condition {
|
||||
DialPeerCondition::Disconnected
|
||||
if this.network.is_disconnected(&peer_id) =>
|
||||
{
|
||||
ExpandedSwarm::dial(this, &peer_id)
|
||||
}
|
||||
if this.network.is_disconnected(&peer_id) => true,
|
||||
DialPeerCondition::NotDialing
|
||||
if !this.network.is_dialing(&peer_id) =>
|
||||
{
|
||||
ExpandedSwarm::dial(this, &peer_id)
|
||||
}
|
||||
_ => {
|
||||
log::trace!("Condition for new dialing attempt to {:?} not met: {:?}",
|
||||
peer_id, condition);
|
||||
if let Some(mut peer) = this.network.peer(peer_id.clone()).into_dialing() {
|
||||
let addrs = this.behaviour.addresses_of_peer(peer.id());
|
||||
peer.connection().add_addresses(addrs);
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
if !this.network.is_dialing(&peer_id) => true,
|
||||
_ => false
|
||||
};
|
||||
match result {
|
||||
Ok(false) => {},
|
||||
Ok(true) => return Poll::Ready(SwarmEvent::Dialing(peer_id)),
|
||||
Err(err) => {
|
||||
log::debug!("Initiating dialing attempt to {:?} failed: {:?}",
|
||||
&peer_id, err);
|
||||
this.behaviour.inject_dial_failure(&peer_id);
|
||||
|
||||
if condition_matched {
|
||||
if let Ok(true) = ExpandedSwarm::dial(this, &peer_id) {
|
||||
return Poll::Ready(SwarmEvent::Dialing(peer_id));
|
||||
}
|
||||
|
||||
} else {
|
||||
log::trace!("Condition for new dialing attempt to {:?} not met: {:?}",
|
||||
peer_id, condition);
|
||||
if let Some(mut peer) = this.network.peer(peer_id.clone()).into_dialing() {
|
||||
let addrs = this.behaviour.addresses_of_peer(peer.id());
|
||||
peer.connection().add_addresses(addrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user