From ab6fecd9f3ba0558ffd5cf99530d9970a13a8fc9 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Wed, 27 Jan 2021 12:05:35 +0200 Subject: [PATCH] Fix DialPeerCondition::Always handling (#1937) * fix: always dial with condition Always * chore: changelog note * refactor: exhaustive DialPeerCondition matching Co-authored-by: Roman Borschel --- swarm/CHANGELOG.md | 3 +++ swarm/src/lib.rs | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 1506351e4e3..65d5e6c86b2 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -2,6 +2,9 @@ - Make `OneShotHandler`s `max_dial_negotiate` limit configurable. [PR 1936](https://github.com/libp2p/rust-libp2p/pull/1936). + +- Fix handling of DialPeerCondition::Always. + [PR 1937](https://github.com/libp2p/rust-libp2p/pull/1937). # 0.27.0 [2021-01-12] diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 77dd4605399..540c2318911 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -691,11 +691,9 @@ where TBehaviour: NetworkBehaviour, this.behaviour.inject_dial_failure(&peer_id); } else { let condition_matched = match condition { - DialPeerCondition::Disconnected - if this.network.is_disconnected(&peer_id) => true, - DialPeerCondition::NotDialing - if !this.network.is_dialing(&peer_id) => true, - _ => false + DialPeerCondition::Disconnected => this.network.is_disconnected(&peer_id), + DialPeerCondition::NotDialing => !this.network.is_dialing(&peer_id), + DialPeerCondition::Always => true, }; if condition_matched { if ExpandedSwarm::dial(this, &peer_id).is_ok() {