Files
reth/crates/net/discv4/src/error.rs
Matthias Seitz ce64fefd78 feat(net): add discv4 crate (#113)
* port kad

* feat: port kad bucket

* feat: add discv4

* chore: rustfmt

* cargo update

* just reuse discv5 table

* test: add rlp tests

* message encoding

* feat: impl codec roundtrip testing

* more work in message handling

* implement ping

* feat: impl commands

* cleanup

* more cleanup

* trim config

* more docs

* feat: implement recursive lookup

* docs

* cleanup config

* feat: implement update stream

* chore: config cleanup

* docs: add crate docs

* feat: more testing

* fix deny

* clarify ring

* docs: more docs

* use discv5 master

* docs: address review and add comments

* update readme

* rustmft

* chore(clippy): make clippy happy
2022-10-25 14:23:24 +02:00

37 lines
1.1 KiB
Rust

//! Error types that can occur in this crate.
use tokio::sync::{mpsc::error::SendError, oneshot::error::RecvError};
/// Error thrown when decoding a UDP packet.
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum DecodePacketError {
#[error("Failed to rlp decode: {0:?}")]
Rlp(#[from] reth_rlp::DecodeError),
#[error("Received packet len too short.")]
PacketTooShort,
#[error("Hash of the header not equals to the hash of the data.")]
HashMismatch,
#[error("Message id {0} is not supported.")]
UnknownMessage(u8),
#[error("Failed to recover public key: {0:?}")]
Secp256k1(#[from] secp256k1::Error),
}
/// High level errors that can occur when interacting with the discovery service
#[derive(Debug, thiserror::Error)]
pub enum Discv4Error {
/// Failed to send a command over the channel
#[error("Failed to send on a closed channel")]
Send,
/// Failed to receive a command response
#[error(transparent)]
Receive(#[from] RecvError),
}
impl<T> From<SendError<T>> for Discv4Error {
fn from(_: SendError<T>) -> Self {
Discv4Error::Send
}
}