mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix various clippy (#6020)
Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
@ -9,38 +9,73 @@ use std::io;
|
||||
|
||||
/// Errors when sending/receiving p2p messages. These should result in kicking the peer.
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum P2PStreamError {
|
||||
/// I/O error.
|
||||
#[error(transparent)]
|
||||
Io(#[from] io::Error),
|
||||
|
||||
/// RLP encoding/decoding error.
|
||||
#[error(transparent)]
|
||||
Rlp(#[from] alloy_rlp::Error),
|
||||
|
||||
/// Error in compression/decompression using Snappy.
|
||||
#[error(transparent)]
|
||||
Snap(#[from] snap::Error),
|
||||
|
||||
/// Error during the P2P handshake.
|
||||
#[error(transparent)]
|
||||
HandshakeError(#[from] P2PHandshakeError),
|
||||
|
||||
/// Message size exceeds maximum length error.
|
||||
#[error("message size ({message_size}) exceeds max length ({max_size})")]
|
||||
MessageTooBig { message_size: usize, max_size: usize },
|
||||
MessageTooBig {
|
||||
/// The actual size of the message received.
|
||||
message_size: usize,
|
||||
/// The maximum allowed size for the message.
|
||||
max_size: usize,
|
||||
},
|
||||
|
||||
/// Unknown reserved P2P message ID error.
|
||||
#[error("unknown reserved p2p message id: {0}")]
|
||||
UnknownReservedMessageId(u8),
|
||||
|
||||
/// Empty protocol message received error.
|
||||
#[error("empty protocol message received")]
|
||||
EmptyProtocolMessage,
|
||||
|
||||
/// Error related to the Pinger.
|
||||
#[error(transparent)]
|
||||
PingerError(#[from] PingerError),
|
||||
|
||||
/// Ping timeout error.
|
||||
#[error("ping timed out with")]
|
||||
PingTimeout,
|
||||
|
||||
/// Error parsing shared capabilities.
|
||||
#[error(transparent)]
|
||||
ParseSharedCapability(#[from] SharedCapabilityError),
|
||||
|
||||
/// Capability not supported on the stream to this peer.
|
||||
#[error("capability not supported on stream to this peer")]
|
||||
CapabilityNotShared,
|
||||
|
||||
/// Mismatched protocol version error.
|
||||
#[error("mismatched protocol version in Hello message: {0}")]
|
||||
MismatchedProtocolVersion(GotExpected<ProtocolVersion>),
|
||||
|
||||
/// Ping started before the handshake completed.
|
||||
#[error("started ping task before the handshake completed")]
|
||||
PingBeforeHandshake,
|
||||
|
||||
/// Too many messages buffered before sending.
|
||||
#[error("too many messages buffered before sending")]
|
||||
SendBufferFull,
|
||||
|
||||
/// Disconnected error.
|
||||
#[error("disconnected")]
|
||||
Disconnected(DisconnectReason),
|
||||
|
||||
/// Unknown disconnect reason error.
|
||||
#[error("unknown disconnect reason: {0}")]
|
||||
UnknownDisconnectReason(#[from] UnknownDisconnectReason),
|
||||
}
|
||||
@ -60,22 +95,34 @@ impl P2PStreamError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Errors when conducting a p2p handshake
|
||||
/// Errors when conducting a p2p handshake.
|
||||
#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum P2PHandshakeError {
|
||||
/// Hello message received/sent outside of handshake error.
|
||||
#[error("hello message can only be recv/sent in handshake")]
|
||||
HelloNotInHandshake,
|
||||
|
||||
/// Received a non-hello message when trying to handshake.
|
||||
#[error("received non-hello message when trying to handshake")]
|
||||
NonHelloMessageInHandshake,
|
||||
|
||||
/// No capabilities shared with the peer.
|
||||
#[error("no capabilities shared with peer")]
|
||||
NoSharedCapabilities,
|
||||
|
||||
/// No response received when sending out handshake.
|
||||
#[error("no response received when sending out handshake")]
|
||||
NoResponse,
|
||||
|
||||
/// Handshake timed out.
|
||||
#[error("handshake timed out")]
|
||||
Timeout,
|
||||
|
||||
/// Disconnected by peer with a specific reason.
|
||||
#[error("disconnected by peer: {0}")]
|
||||
Disconnected(DisconnectReason),
|
||||
|
||||
/// Error decoding a message during handshake.
|
||||
#[error("error decoding a message during handshake: {0}")]
|
||||
DecodeError(#[from] alloy_rlp::Error),
|
||||
}
|
||||
|
||||
@ -44,7 +44,6 @@ macro_rules! fuzz_type_and_name {
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[cfg(any(test, feature = "bench"))]
|
||||
pub mod fuzz_rlp {
|
||||
use crate::roundtrip_encoding;
|
||||
|
||||
@ -284,38 +284,49 @@ impl Borrow<(PeerId, GetBlockHeaders)> for RespondedGetBlockHeaders {
|
||||
|
||||
/// All `eth` request related to blocks delegated by the network.
|
||||
#[derive(Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum IncomingEthRequest {
|
||||
/// Request Block headers from the peer.
|
||||
///
|
||||
/// The response should be sent through the channel.
|
||||
GetBlockHeaders {
|
||||
/// The ID of the peer to request block headers from.
|
||||
peer_id: PeerId,
|
||||
/// The specific block headers requested.
|
||||
request: GetBlockHeaders,
|
||||
/// The channel sender for the response containing block headers.
|
||||
response: oneshot::Sender<RequestResult<BlockHeaders>>,
|
||||
},
|
||||
/// Request Block headers from the peer.
|
||||
/// Request Block bodies from the peer.
|
||||
///
|
||||
/// The response should be sent through the channel.
|
||||
GetBlockBodies {
|
||||
/// The ID of the peer to request block bodies from.
|
||||
peer_id: PeerId,
|
||||
/// The specific block bodies requested.
|
||||
request: GetBlockBodies,
|
||||
/// The channel sender for the response containing block bodies.
|
||||
response: oneshot::Sender<RequestResult<BlockBodies>>,
|
||||
},
|
||||
/// Request Node Data from the peer.
|
||||
///
|
||||
/// The response should be sent through the channel.
|
||||
GetNodeData {
|
||||
/// The ID of the peer to request node data from.
|
||||
peer_id: PeerId,
|
||||
/// The specific node data requested.
|
||||
request: GetNodeData,
|
||||
/// The channel sender for the response containing node data.
|
||||
response: oneshot::Sender<RequestResult<NodeData>>,
|
||||
},
|
||||
/// Request Receipts from the peer.
|
||||
///
|
||||
/// The response should be sent through the channel.
|
||||
GetReceipts {
|
||||
/// The ID of the peer to request receipts from.
|
||||
peer_id: PeerId,
|
||||
/// The specific receipts requested.
|
||||
request: GetReceipts,
|
||||
/// The channel sender for the response containing receipts.
|
||||
response: oneshot::Sender<RequestResult<Receipts>>,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user