Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: misc raw message #13006

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion crates/net/eth-wire/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -38,7 +54,7 @@ pub enum CapabilityMessage<N: NetworkPrimitives = EthNetworkPrimitives> {
serde(bound = "EthMessage<N>: Serialize + serde::de::DeserializeOwned")
)]
Eth(EthMessage<N>),
/// Any other capability message.
/// Any other or manually crafted eth message.
Other(RawCapabilityMessage),
}

Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum PeerMessage<N: NetworkPrimitives = EthNetworkPrimitives> {
PooledTransactions(NewPooledTransactionHashes),
/// All `eth` request variants.
EthRequest(PeerRequest<N>),
/// Other than eth namespace message
/// Any other or manually crafted eth message.
Other(RawCapabilityMessage),
}

Expand Down
Loading