Skip to content

Commit

Permalink
MaybeSerdeBincodeCompat
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Nov 28, 2024
1 parent f9b9408 commit 7119aba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion crates/primitives-traits/src/block/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use alloc::{fmt, vec::Vec};

use alloy_eips::eip4895::Withdrawals;

use crate::{FullSignedTx, InMemorySize, MaybeArbitrary, MaybeSerde, SignedTransaction};
use crate::{
FullSignedTx, InMemorySize, MaybeArbitrary, MaybeSerde, MaybeSerdeBincodeCompat,
SignedTransaction,
};

/// Helper trait that unifies all behaviour required by transaction to support full node operations.
pub trait FullBlockBody: BlockBody<Transaction: FullSignedTx> {}
Expand All @@ -26,6 +29,7 @@ pub trait BlockBody:
+ InMemorySize
+ MaybeSerde
+ MaybeArbitrary
+ MaybeSerdeBincodeCompat
{
/// Ordered list of signed transactions as committed in block.
type Transaction: SignedTransaction;
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives-traits/src/block/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::fmt;

use alloy_primitives::Sealable;

use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde, MaybeSerdeBincodeCompat};

/// Helper trait that unifies all behaviour required by block header to support full node
/// operations.
Expand All @@ -29,6 +29,7 @@ pub trait BlockHeader:
+ InMemorySize
+ MaybeSerde
+ MaybeArbitrary
+ MaybeSerdeBincodeCompat
{
}

Expand Down
13 changes: 13 additions & 0 deletions crates/primitives-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,16 @@ pub trait MaybeCompact {}
impl<T> MaybeCompact for T where T: reth_codecs::Compact {}
#[cfg(not(feature = "reth-codec"))]
impl<T> MaybeCompact for T {}

/// Helper trait that requires serde bincode compatibility implementation.
#[cfg(feature = "serde-bincode-compat")]
pub trait MaybeSerdeBincodeCompat: crate::serde_bincode_compat::SerdeBincodeCompat {}
/// Noop. Helper trait that would require serde bincode compatibility implementation if
/// `serde-bincode-compat` feature were enabled.
#[cfg(not(feature = "serde-bincode-compat"))]
pub trait MaybeSerdeBincodeCompat {}

#[cfg(feature = "serde-bincode-compat")]
impl<T> MaybeSerdeBincodeCompat for T where T: crate::serde_bincode_compat::SerdeBincodeCompat {}
#[cfg(not(feature = "serde-bincode-compat"))]
impl<T> MaybeSerdeBincodeCompat for T {}

0 comments on commit 7119aba

Please sign in to comment.