diff --git a/crates/net/eth-wire/src/capability.rs b/crates/net/eth-wire/src/capability.rs index 625971e0e7..3d8c61800e 100644 --- a/crates/net/eth-wire/src/capability.rs +++ b/crates/net/eth-wire/src/capability.rs @@ -27,6 +27,22 @@ pub struct RawCapabilityMessage { pub payload: Bytes, } +impl RawCapabilityMessage { + /// Creates a new capability message with the given id and payload. + pub const fn new(id: usize, payload: Bytes) -> Self { + Self { id, payload } + } + + /// Creates a raw message for the eth sub-protocol. + /// + /// Caller must ensure that the rlp encoded `payload` matches the given `id`. + /// + /// See also [`EthMessage`] + pub const fn eth(id: EthMessageID, payload: Bytes) -> Self { + Self::new(id as usize, payload) + } +} + /// Various protocol related event types bubbled up from a session that need to be handled by the /// network. #[derive(Debug)] @@ -38,7 +54,7 @@ pub enum CapabilityMessage { serde(bound = "EthMessage: Serialize + serde::de::DeserializeOwned") )] Eth(EthMessage), - /// Any other capability message. + /// Any other or manually crafted eth message. Other(RawCapabilityMessage), } diff --git a/crates/net/network/src/message.rs b/crates/net/network/src/message.rs index 199498b0b4..e88ccb54c3 100644 --- a/crates/net/network/src/message.rs +++ b/crates/net/network/src/message.rs @@ -55,7 +55,7 @@ pub enum PeerMessage { PooledTransactions(NewPooledTransactionHashes), /// All `eth` request variants. EthRequest(PeerRequest), - /// Other than eth namespace message + /// Any other or manually crafted eth message. Other(RawCapabilityMessage), }