Skip to content

Commit c427bb3

Browse files
protocols/kad: Implement Error for GetRecordError (#2614)
1 parent 7ce9fb4 commit c427bb3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

protocols/kad/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- Update to `libp2p-swarm` `v0.36.0`.
66

7+
- Derive `Error` for `GetRecordError` (see [PR 2614]).
8+
9+
[pr 2614]: https://github.com/libp2p/rust-libp2p/pull/2614
10+
711
# 0.36.0
812

913
- Update to `libp2p-swarm` `v0.35.0`.

protocols/kad/src/behaviour.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2555,17 +2555,20 @@ pub struct GetRecordOk {
25552555
}
25562556

25572557
/// The error result of [`Kademlia::get_record`].
2558-
#[derive(Debug, Clone)]
2558+
#[derive(Debug, Clone, Error)]
25592559
pub enum GetRecordError {
2560+
#[error("the record was not found")]
25602561
NotFound {
25612562
key: record::Key,
25622563
closest_peers: Vec<PeerId>,
25632564
},
2565+
#[error("the quorum failed; needed {quorum} peers")]
25642566
QuorumFailed {
25652567
key: record::Key,
25662568
records: Vec<PeerRecord>,
25672569
quorum: NonZeroUsize,
25682570
},
2571+
#[error("the request timed out")]
25692572
Timeout {
25702573
key: record::Key,
25712574
records: Vec<PeerRecord>,

0 commit comments

Comments
 (0)