mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-25 11:02:12 +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:
parent
77a34c0a0d
commit
87b5efb3e8
@ -1,6 +1,11 @@
|
||||
# Version ???
|
||||
|
||||
|
||||
# Version 0.18.1 (2020-04-17)
|
||||
|
||||
- `libp2p-swarm`: Make sure inject_dial_failure is called in all situations.
|
||||
[PR 1549](https://github.com/libp2p/rust-libp2p/pull/1549)
|
||||
|
||||
# Version 0.18.0 (2020-04-09)
|
||||
|
||||
- `libp2p-core`: Treat connection limit errors as pending connection errors.
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "libp2p"
|
||||
edition = "2018"
|
||||
description = "Peer-to-peer networking library"
|
||||
version = "0.18.0"
|
||||
version = "0.18.1"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/libp2p/rust-libp2p"
|
||||
@ -68,7 +68,7 @@ libp2p-pnet = { version = "0.18.0", path = "protocols/pnet", optional = true }
|
||||
libp2p-core = { version = "0.18.0", path = "core" }
|
||||
libp2p-core-derive = { version = "0.18.0", path = "misc/core-derive" }
|
||||
libp2p-secio = { version = "0.18.0", path = "protocols/secio", default-features = false, optional = true }
|
||||
libp2p-swarm = { version = "0.18.0", path = "swarm" }
|
||||
libp2p-swarm = { version = "0.18.1", path = "swarm" }
|
||||
libp2p-uds = { version = "0.18.0", path = "transports/uds", optional = true }
|
||||
libp2p-wasm-ext = { version = "0.18.0", path = "transports/wasm-ext", optional = true }
|
||||
libp2p-yamux = { version = "0.18.0", path = "muxers/yamux", optional = true }
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "libp2p-swarm"
|
||||
edition = "2018"
|
||||
description = "The libp2p swarm"
|
||||
version = "0.18.0"
|
||||
version = "0.18.1"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/libp2p/rust-libp2p"
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user