Skip to content

Commit 1aa4337

Browse files
authored
feat(kad): impl Copy for kademlia query progression types
Implement `Copy` for the following basic kademlia types in `OutboundQueryProgressed`: - QueryStats - ProgressStep Pull-Request: #6083.
1 parent 70082df commit 1aa4337

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ libp2p-floodsub = { version = "0.47.0", path = "protocols/floodsub" }
8585
libp2p-gossipsub = { version = "0.49.0", path = "protocols/gossipsub" }
8686
libp2p-identify = { version = "0.47.0", path = "protocols/identify" }
8787
libp2p-identity = { version = "0.2.12" }
88-
libp2p-kad = { version = "0.48.0", path = "protocols/kad" }
88+
libp2p-kad = { version = "0.48.1", path = "protocols/kad" }
8989
libp2p-mdns = { version = "0.48.0", path = "protocols/mdns" }
9090
libp2p-memory-connection-limits = { version = "0.5.0", path = "misc/memory-connection-limits" }
9191
libp2p-metrics = { version = "0.17.0", path = "misc/metrics" }

protocols/kad/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.48.1
2+
3+
- Implement `Copy` for `QueryStats` and `ProgressStep`
4+
See [PR 6083](https://github.com/libp2p/rust-libp2p/pull/6083)
5+
16
## 0.48.0
27

38
- Configurable outbound_substreams_timeout.

protocols/kad/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-kad"
33
edition.workspace = true
44
rust-version = { workspace = true }
55
description = "Kademlia protocol for libp2p"
6-
version = "0.48.0"
6+
version = "0.48.1"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

protocols/kad/src/behaviour.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ where
823823
} else {
824824
QueryInfo::GetRecord {
825825
key,
826-
step: step.clone(),
826+
step,
827827
found_a_record: false,
828828
cache_candidates: BTreeMap::new(),
829829
}
@@ -1079,7 +1079,7 @@ where
10791079
key: key.clone(),
10801080
providers_found: providers.len(),
10811081
step: if providers.is_empty() {
1082-
step.clone()
1082+
step
10831083
} else {
10841084
step.next()
10851085
},
@@ -2367,7 +2367,7 @@ where
23672367
let peers = closer_peers.iter().chain(provider_peers.iter());
23682368
self.discovered(&query_id, &source, peers);
23692369
if let Some(query) = self.queries.get_mut(&query_id) {
2370-
let stats = query.stats().clone();
2370+
let stats = *query.stats();
23712371
if let QueryInfo::GetProviders {
23722372
ref key,
23732373
ref mut providers_found,
@@ -2387,7 +2387,7 @@ where
23872387
providers,
23882388
},
23892389
)),
2390-
step: step.clone(),
2390+
step: *step,
23912391
stats,
23922392
},
23932393
));
@@ -2461,7 +2461,7 @@ where
24612461
query_id,
24622462
} => {
24632463
if let Some(query) = self.queries.get_mut(&query_id) {
2464-
let stats = query.stats().clone();
2464+
let stats = *query.stats();
24652465
if let QueryInfo::GetRecord {
24662466
key,
24672467
ref mut step,
@@ -2482,7 +2482,7 @@ where
24822482
result: QueryResult::GetRecord(Ok(GetRecordOk::FoundRecord(
24832483
record,
24842484
))),
2485-
step: step.clone(),
2485+
step: *step,
24862486
stats,
24872487
},
24882488
));
@@ -2830,7 +2830,7 @@ pub enum Event {
28302830
}
28312831

28322832
/// Information about progress events.
2833-
#[derive(Debug, Clone)]
2833+
#[derive(Clone, Copy, Debug)]
28342834
pub struct ProgressStep {
28352835
/// The index into the event
28362836
pub count: NonZeroUsize,

protocols/kad/src/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl Query {
464464
}
465465

466466
/// Execution statistics of a query.
467-
#[derive(Clone, Debug, PartialEq, Eq)]
467+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
468468
pub struct QueryStats {
469469
requests: u32,
470470
success: u32,

0 commit comments

Comments
 (0)