From 67ebcdeb05c4189db4ff820a974f84779ed3e81d Mon Sep 17 00:00:00 2001 From: joshuef Date: Thu, 4 Apr 2024 23:44:08 +0900 Subject: [PATCH] feat(kad): only dial if not connected AND not dialing Pull-Request: #4957. --- protocols/kad/CHANGELOG.md | 7 +++++-- protocols/kad/src/behaviour.rs | 9 ++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 38809b8aafa..b2a06dc691c 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -4,6 +4,8 @@ See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) - Update to DHT republish interval and expiration time defaults to 22h and 48h respectively, rationale in [libp2p/specs#451](https://github.com/libp2p/specs/pull/451) See [PR 3230](https://github.com/libp2p/rust-libp2p/pull/3230) +- Use default dial conditions more consistently. + See [PR 4957](https://github.com/libp2p/rust-libp2p/pull/4957) - QueryClose progress whenever closer in range, instead of having to be the closest. See [PR 4934](https://github.com/libp2p/rust-libp2p/pull/4934). - Add periodic and automatic bootstrap. @@ -67,6 +69,7 @@ --> ## 0.44.5 + - Migrate to `quick-protobuf-codec` crate for codec logic. See [PR 4501]. @@ -192,7 +195,7 @@ - Instead of a single event `OutboundQueryCompleted`, there are now multiple events emitted, allowing the user to process them as they come in (via the new `OutboundQueryProgressed`). See `ProgressStep` to identify the final `OutboundQueryProgressed` of a single query. - To finish a query early, i.e. before the final `OutboundQueryProgressed` of the query, a caller needs to call `query.finish()`. - There is no more automatic caching of records. The user has to manually call `put_record_to` on the `QueryInfo::GetRecord.cache_candidates` to cache a record to a close peer that did not return the record on the foregone query. - See [PR 2712]. + See [PR 2712]. [PR 3085]: https://github.com/libp2p/rust-libp2p/pull/3085 [PR 3011]: https://github.com/libp2p/rust-libp2p/pull/3011 @@ -271,7 +274,7 @@ - Require owned key in `get_record()` method (see [PR 2477]). -- Merge NetworkBehaviour's inject_\* paired methods (see PR 2445). +- Merge NetworkBehaviour's inject\_\* paired methods (see PR 2445). [PR 2477]: https://github.com/libp2p/rust-libp2p/pull/2477 [PR 2445]: https://github.com/libp2p/rust-libp2p/pull/2445 diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 77ce78da237..7f47f93bb39 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -628,9 +628,7 @@ where } kbucket::InsertResult::Pending { disconnected } => { self.queued_events.push_back(ToSwarm::Dial { - opts: DialOpts::peer_id(disconnected.into_preimage()) - .condition(dial_opts::PeerCondition::NotDialing) - .build(), + opts: DialOpts::peer_id(disconnected.into_preimage()).build(), }); RoutingUpdate::Pending } @@ -1375,7 +1373,6 @@ where if !self.connected_peers.contains(disconnected.preimage()) { self.queued_events.push_back(ToSwarm::Dial { opts: DialOpts::peer_id(disconnected.into_preimage()) - .condition(dial_opts::PeerCondition::NotDialing) .build(), }) } @@ -2595,9 +2592,7 @@ where } else if &peer_id != self.kbuckets.local_key().preimage() { query.inner.pending_rpcs.push((peer_id, event)); self.queued_events.push_back(ToSwarm::Dial { - opts: DialOpts::peer_id(peer_id) - .condition(dial_opts::PeerCondition::NotDialing) - .build(), + opts: DialOpts::peer_id(peer_id).build(), }); } }