Skip to content

Commit

Permalink
protocols/kad: Implement Error for GetRecordError (#2614)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janmajayamall authored Apr 17, 2022
1 parent 7ce9fb4 commit c427bb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

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

- Derive `Error` for `GetRecordError` (see [PR 2614]).

[pr 2614]: https://github.com/libp2p/rust-libp2p/pull/2614

# 0.36.0

- Update to `libp2p-swarm` `v0.35.0`.
Expand Down
5 changes: 4 additions & 1 deletion protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2555,17 +2555,20 @@ pub struct GetRecordOk {
}

/// The error result of [`Kademlia::get_record`].
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Error)]
pub enum GetRecordError {
#[error("the record was not found")]
NotFound {
key: record::Key,
closest_peers: Vec<PeerId>,
},
#[error("the quorum failed; needed {quorum} peers")]
QuorumFailed {
key: record::Key,
records: Vec<PeerRecord>,
quorum: NonZeroUsize,
},
#[error("the request timed out")]
Timeout {
key: record::Key,
records: Vec<PeerRecord>,
Expand Down

0 comments on commit c427bb3

Please sign in to comment.