mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(sdk): Add NodePrimitives::BlockHeader and NodePrimitives::BlockBody (#12647)
This commit is contained in:
@ -100,4 +100,4 @@ reth-codec = [
|
||||
"dep:reth-codecs",
|
||||
"dep:modular-bitfield",
|
||||
"dep:byteorder",
|
||||
]
|
||||
]
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
use core::fmt;
|
||||
|
||||
use crate::{BlockBody, FullBlock, FullReceipt, FullSignedTx, FullTxType, MaybeSerde};
|
||||
use crate::{
|
||||
FullBlock, FullBlockBody, FullBlockHeader, FullReceipt, FullSignedTx, FullTxType, MaybeSerde,
|
||||
};
|
||||
|
||||
/// Configures all the primitive types of the node.
|
||||
pub trait NodePrimitives:
|
||||
@ -17,6 +19,28 @@ pub trait NodePrimitives:
|
||||
+ Eq
|
||||
+ MaybeSerde
|
||||
+ 'static;
|
||||
/// Block header primitive.
|
||||
type BlockHeader: Send
|
||||
+ Sync
|
||||
+ Unpin
|
||||
+ Clone
|
||||
+ Default
|
||||
+ fmt::Debug
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ MaybeSerde
|
||||
+ 'static;
|
||||
/// Block body primitive.
|
||||
type BlockBody: Send
|
||||
+ Sync
|
||||
+ Unpin
|
||||
+ Clone
|
||||
+ Default
|
||||
+ fmt::Debug
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ MaybeSerde
|
||||
+ 'static;
|
||||
/// Signed version of the transaction type.
|
||||
type SignedTx: Send
|
||||
+ Sync
|
||||
@ -45,6 +69,8 @@ pub trait NodePrimitives:
|
||||
|
||||
impl NodePrimitives for () {
|
||||
type Block = ();
|
||||
type BlockHeader = ();
|
||||
type BlockBody = ();
|
||||
type SignedTx = ();
|
||||
type TxType = ();
|
||||
type Receipt = ();
|
||||
@ -55,7 +81,11 @@ pub trait FullNodePrimitives:
|
||||
Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + 'static
|
||||
{
|
||||
/// Block primitive.
|
||||
type Block: FullBlock<Body: BlockBody<Transaction = Self::SignedTx>>;
|
||||
type Block: FullBlock<Header = Self::BlockHeader, Body = Self::BlockBody>;
|
||||
/// Block header primitive.
|
||||
type BlockHeader: FullBlockHeader + 'static;
|
||||
/// Block body primitive.
|
||||
type BlockBody: FullBlockBody<Transaction = Self::SignedTx> + 'static;
|
||||
/// Signed version of the transaction type.
|
||||
type SignedTx: FullSignedTx;
|
||||
/// Transaction envelope type ID.
|
||||
@ -66,9 +96,11 @@ pub trait FullNodePrimitives:
|
||||
|
||||
impl<T> NodePrimitives for T
|
||||
where
|
||||
T: FullNodePrimitives<Block: 'static, SignedTx: 'static, Receipt: 'static, TxType: 'static>,
|
||||
T: FullNodePrimitives,
|
||||
{
|
||||
type Block = T::Block;
|
||||
type BlockHeader = T::BlockHeader;
|
||||
type BlockBody = T::BlockBody;
|
||||
type SignedTx = T::SignedTx;
|
||||
type TxType = T::TxType;
|
||||
type Receipt = T::Receipt;
|
||||
|
||||
Reference in New Issue
Block a user