reth_eth_wire_types/
primitives.rs1use alloy_consensus::{RlpDecodableReceipt, RlpEncodableReceipt, TxReceipt};
4use alloy_rlp::{Decodable, Encodable};
5use core::fmt::Debug;
6use reth_primitives_traits::{Block, BlockBody, BlockHeader, NodePrimitives, SignedTransaction};
7
8pub trait NetworkPrimitives: Send + Sync + Unpin + Clone + Debug + 'static {
11 type BlockHeader: BlockHeader + 'static;
13
14 type BlockBody: BlockBody + 'static;
16
17 type Block: Block<Header = Self::BlockHeader, Body = Self::BlockBody>
19 + Encodable
20 + Decodable
21 + 'static;
22
23 type BroadcastedTransaction: SignedTransaction + 'static;
27
28 type PooledTransaction: SignedTransaction + TryFrom<Self::BroadcastedTransaction> + 'static;
30
31 type Receipt: TxReceipt
33 + RlpEncodableReceipt
34 + RlpDecodableReceipt
35 + Encodable
36 + Decodable
37 + Unpin
38 + 'static;
39}
40
41pub trait NetPrimitivesFor<N: NodePrimitives>:
44 NetworkPrimitives<
45 BlockHeader = N::BlockHeader,
46 BlockBody = N::BlockBody,
47 Block = N::Block,
48 Receipt = N::Receipt,
49>
50{
51}
52
53impl<N, T> NetPrimitivesFor<N> for T
54where
55 N: NodePrimitives,
56 T: NetworkPrimitives<
57 BlockHeader = N::BlockHeader,
58 BlockBody = N::BlockBody,
59 Block = N::Block,
60 Receipt = N::Receipt,
61 >,
62{
63}
64
65#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
67#[non_exhaustive]
68pub struct EthNetworkPrimitives;
69
70impl NetworkPrimitives for EthNetworkPrimitives {
71 type BlockHeader = alloy_consensus::Header;
72 type BlockBody = reth_ethereum_primitives::BlockBody;
73 type Block = reth_ethereum_primitives::Block;
74 type BroadcastedTransaction = reth_ethereum_primitives::TransactionSigned;
75 type PooledTransaction = reth_ethereum_primitives::PooledTransactionVariant;
76 type Receipt = reth_ethereum_primitives::Receipt;
77}