chore(sdk): make Chain generic over data primitives (#12635)

This commit is contained in:
Emilia Hane
2024-11-19 10:27:23 +01:00
committed by GitHub
parent e859e1711d
commit 06bf5c7783
7 changed files with 86 additions and 52 deletions

View File

@ -3,15 +3,44 @@ use core::fmt;
use crate::{BlockBody, FullBlock, FullReceipt, FullSignedTx, FullTxType, MaybeSerde};
/// Configures all the primitive types of the node.
pub trait NodePrimitives: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static {
pub trait NodePrimitives:
Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + 'static
{
/// Block primitive.
type Block: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static;
type Block: Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ PartialEq
+ Eq
+ MaybeSerde
+ 'static;
/// Signed version of the transaction type.
type SignedTx: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static;
type SignedTx: Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ PartialEq
+ Eq
+ MaybeSerde
+ 'static;
/// Transaction envelope type ID.
type TxType: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
type TxType: Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + 'static;
/// A receipt.
type Receipt: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static;
type Receipt: Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ PartialEq
+ Eq
+ MaybeSerde
+ 'static;
}
impl NodePrimitives for () {
@ -22,7 +51,9 @@ impl NodePrimitives for () {
}
/// Helper trait that sets trait bounds on [`NodePrimitives`].
pub trait FullNodePrimitives: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static {
pub trait FullNodePrimitives:
Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + 'static
{
/// Block primitive.
type Block: FullBlock<Body: BlockBody<Transaction = Self::SignedTx>>;
/// Signed version of the transaction type.