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

feat: bound NetworkPrimitives types by proper traits #13196

Merged
merged 1 commit into from
Dec 9, 2024
Merged
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
43 changes: 4 additions & 39 deletions crates/net/eth-wire-types/src/primitives.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Abstraction over primitive types in network messages.

use alloy_rlp::{Decodable, Encodable};
use reth_primitives_traits::{Block, BlockHeader, SignedTransaction};
use reth_primitives_traits::{Block, BlockBody, BlockHeader, SignedTransaction};
use std::fmt::Debug;

/// Abstraction over primitive types which might appear in network messages. See
Expand All @@ -10,56 +10,21 @@ pub trait NetworkPrimitives:
Send + Sync + Unpin + Clone + Debug + PartialEq + Eq + 'static
{
/// The block header type.
type BlockHeader: BlockHeader
+ Encodable
+ Decodable
+ Send
+ Sync
+ Unpin
+ Clone
+ Debug
+ PartialEq
+ Eq
+ 'static;
type BlockHeader: BlockHeader + 'static;

/// The block body type.
type BlockBody: Encodable
+ Decodable
+ Send
+ Sync
+ Unpin
+ Clone
+ Debug
+ PartialEq
+ Eq
+ 'static;
type BlockBody: BlockBody + 'static;

/// Full block type.
type Block: Block<Header = Self::BlockHeader, Body = Self::BlockBody>
+ Encodable
+ Decodable
+ Send
+ Sync
+ Unpin
+ Clone
+ Debug
+ PartialEq
+ Eq
+ 'static;

/// The transaction type which peers announce in `Transactions` messages. It is different from
/// `PooledTransactions` to account for Ethereum case where EIP-4844 transactions are not being
/// announced and can only be explicitly requested from peers.
type BroadcastedTransaction: Encodable
+ Decodable
+ Send
+ Sync
+ Unpin
+ Clone
+ Debug
+ PartialEq
+ Eq
+ 'static;
type BroadcastedTransaction: SignedTransaction + 'static;

/// The transaction type which peers return in `PooledTransactions` messages.
type PooledTransaction: SignedTransaction + TryFrom<Self::BroadcastedTransaction> + 'static;
Expand Down
Loading