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