reth_primitives_traits/node.rs
1use crate::{FullBlock, FullBlockBody, FullBlockHeader, FullReceipt, FullSignedTx};
2use core::fmt;
3
4/// Configures all the primitive types of the node.
5///
6/// This trait defines the core types used throughout the node for representing
7/// blockchain data. It serves as the foundation for type consistency across
8/// different node implementations.
9pub trait NodePrimitives:
10 Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + 'static
11{
12 /// Block primitive.
13 type Block: FullBlock<Header = Self::BlockHeader, Body = Self::BlockBody>;
14 /// Block header primitive.
15 type BlockHeader: FullBlockHeader;
16 /// Block body primitive.
17 type BlockBody: FullBlockBody<Transaction = Self::SignedTx, OmmerHeader = Self::BlockHeader>;
18 /// Signed version of the transaction type.
19 ///
20 /// This represents the transaction as it exists in the blockchain - the consensus
21 /// format that includes the signature and can be included in a block.
22 type SignedTx: FullSignedTx;
23 /// A receipt.
24 type Receipt: FullReceipt;
25}
26
27/// Helper adapter type for accessing [`NodePrimitives`] block header types.
28pub type HeaderTy<N> = <N as NodePrimitives>::BlockHeader;
29
30/// Helper adapter type for accessing [`NodePrimitives`] block body types.
31pub type BodyTy<N> = <N as NodePrimitives>::BlockBody;
32
33/// Helper adapter type for accessing [`NodePrimitives`] block types.
34pub type BlockTy<N> = <N as NodePrimitives>::Block;
35
36/// Helper adapter type for accessing [`NodePrimitives`] receipt types.
37pub type ReceiptTy<N> = <N as NodePrimitives>::Receipt;
38
39/// Helper adapter type for accessing [`NodePrimitives`] signed transaction types.
40pub type TxTy<N> = <N as NodePrimitives>::SignedTx;