reth_primitives_traits/
node.rs

1use crate::{
2    Block, FullBlock, FullBlockBody, FullBlockHeader, FullReceipt, FullSignedTx,
3    MaybeSerdeBincodeCompat, Receipt,
4};
5use core::fmt;
6
7/// Configures all the primitive types of the node.
8pub trait NodePrimitives:
9    Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + 'static
10{
11    /// Block primitive.
12    type Block: Block<Header = Self::BlockHeader, Body = Self::BlockBody> + MaybeSerdeBincodeCompat;
13    /// Block header primitive.
14    type BlockHeader: FullBlockHeader;
15    /// Block body primitive.
16    type BlockBody: FullBlockBody<Transaction = Self::SignedTx, OmmerHeader = Self::BlockHeader>;
17    /// Signed version of the transaction type.
18    type SignedTx: FullSignedTx;
19    /// A receipt.
20    type Receipt: Receipt;
21}
22/// Helper trait that sets trait bounds on [`NodePrimitives`].
23pub trait FullNodePrimitives
24where
25    Self: NodePrimitives<
26            Block: FullBlock<Header = Self::BlockHeader, Body = Self::BlockBody>,
27            BlockHeader: FullBlockHeader,
28            BlockBody: FullBlockBody<Transaction = Self::SignedTx>,
29            SignedTx: FullSignedTx,
30            Receipt: FullReceipt,
31        > + Send
32        + Sync
33        + Unpin
34        + Clone
35        + Default
36        + fmt::Debug
37        + PartialEq
38        + Eq
39        + 'static,
40{
41}
42
43impl<T> FullNodePrimitives for T where
44    T: NodePrimitives<
45            Block: FullBlock<Header = Self::BlockHeader, Body = Self::BlockBody>,
46            BlockHeader: FullBlockHeader,
47            BlockBody: FullBlockBody<Transaction = Self::SignedTx>,
48            SignedTx: FullSignedTx,
49            Receipt: FullReceipt,
50        > + Send
51        + Sync
52        + Unpin
53        + Clone
54        + Default
55        + fmt::Debug
56        + PartialEq
57        + Eq
58        + 'static
59{
60}
61
62/// Helper adapter type for accessing [`NodePrimitives`] block header types.
63pub type HeaderTy<N> = <N as NodePrimitives>::BlockHeader;
64
65/// Helper adapter type for accessing [`NodePrimitives`] block body types.
66pub type BodyTy<N> = <N as NodePrimitives>::BlockBody;
67
68/// Helper adapter type for accessing [`NodePrimitives`] block types.
69pub type BlockTy<N> = <N as NodePrimitives>::Block;
70
71/// Helper adapter type for accessing [`NodePrimitives`] receipt types.
72pub type ReceiptTy<N> = <N as NodePrimitives>::Receipt;
73
74/// Helper adapter type for accessing [`NodePrimitives`] signed transaction types.
75pub type TxTy<N> = <N as NodePrimitives>::SignedTx;