protocols/kad: Implement Error for GetRecordError (#2614)

This commit is contained in:
Janmajayamall
2022-04-17 16:16:32 +08:00
committed by GitHub
parent 7ce9fb4fb1
commit c427bb3958
2 changed files with 8 additions and 1 deletions

View File

@@ -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`.

View File

@@ -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>,