reth_eth_wire_types/
primitives.rs
1use 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:
11 Send + Sync + Unpin + Clone + Debug + PartialEq + Eq + 'static
12{
13 type BlockHeader: BlockHeader + 'static;
15
16 type BlockBody: BlockBody + 'static;
18
19 type Block: Block<Header = Self::BlockHeader, Body = Self::BlockBody>
21 + Encodable
22 + Decodable
23 + 'static;
24
25 type BroadcastedTransaction: SignedTransaction + 'static;
29
30 type PooledTransaction: SignedTransaction + TryFrom<Self::BroadcastedTransaction> + 'static;
32
33 type Receipt: TxReceipt + RlpEncodableReceipt + RlpDecodableReceipt + Unpin + 'static;
35}
36
37pub trait NetPrimitivesFor<N: NodePrimitives>:
40 NetworkPrimitives<
41 BlockHeader = N::BlockHeader,
42 BlockBody = N::BlockBody,
43 Block = N::Block,
44 Receipt = N::Receipt,
45>
46{
47}
48
49impl<N, T> NetPrimitivesFor<N> for T
50where
51 N: NodePrimitives,
52 T: NetworkPrimitives<
53 BlockHeader = N::BlockHeader,
54 BlockBody = N::BlockBody,
55 Block = N::Block,
56 Receipt = N::Receipt,
57 >,
58{
59}
60
61#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
63#[non_exhaustive]
64pub struct EthNetworkPrimitives;
65
66impl NetworkPrimitives for EthNetworkPrimitives {
67 type BlockHeader = alloy_consensus::Header;
68 type BlockBody = reth_ethereum_primitives::BlockBody;
69 type Block = reth_ethereum_primitives::Block;
70 type BroadcastedTransaction = reth_ethereum_primitives::TransactionSigned;
71 type PooledTransaction = reth_ethereum_primitives::PooledTransaction;
72 type Receipt = reth_ethereum_primitives::Receipt;
73}