From 91437cc5f32210419a2b1e3142050cfdefe3d2fb Mon Sep 17 00:00:00 2001 From: yHSJ Date: Thu, 8 May 2025 14:06:39 -0400 Subject: [PATCH] chore: store header_body with raw bytes --- pallas-primitives/src/alonzo/model.rs | 12 ++++++------ pallas-primitives/src/babbage/model.rs | 12 ++++++------ pallas-primitives/src/conway/model.rs | 2 +- pallas-traverse/src/hashes.rs | 8 ++++---- pallas-traverse/src/lib.rs | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pallas-primitives/src/alonzo/model.rs b/pallas-primitives/src/alonzo/model.rs index 9e4c32bfc..a49d2209b 100644 --- a/pallas-primitives/src/alonzo/model.rs +++ b/pallas-primitives/src/alonzo/model.rs @@ -68,16 +68,16 @@ pub struct HeaderBody { } #[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] -pub struct Header { - #[n(0)] - pub header_body: HeaderBody, +pub struct Header<'b> { + #[b(0)] + pub header_body: KeepRaw<'b, HeaderBody>, #[n(1)] pub body_signature: Bytes, } -#[deprecated(since = "1.0.0-alpha", note = "use `KeepRaw<'_, Header>` instead")] -pub type MintedHeader<'a> = KeepRaw<'a, Header>; +#[deprecated(since = "1.0.0-alpha", note = "use `KeepRaw<'_, Header<'_>>` instead")] +pub type MintedHeader<'a> = KeepRaw<'a, Header<'a>>; pub type Multiasset = BTreeMap>; @@ -469,7 +469,7 @@ codec_by_datatype! { #[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Clone)] pub struct Block<'b> { #[n(0)] - pub header: KeepRaw<'b, Header>, + pub header: KeepRaw<'b, Header<'b>>, #[b(1)] pub transaction_bodies: Vec>, diff --git a/pallas-primitives/src/babbage/model.rs b/pallas-primitives/src/babbage/model.rs index a93c6c152..9633562ad 100644 --- a/pallas-primitives/src/babbage/model.rs +++ b/pallas-primitives/src/babbage/model.rs @@ -71,16 +71,16 @@ pub struct OperationalCert { } #[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] -pub struct Header { - #[n(0)] - pub header_body: HeaderBody, +pub struct Header<'b> { + #[b(0)] + pub header_body: KeepRaw<'b, HeaderBody>, #[n(1)] pub body_signature: Bytes, } -#[deprecated(since = "1.0.0-alpha", note = "use `KeepRaw<'_, Header>` instead")] -pub type MintedHeader<'a> = KeepRaw<'a, Header>; +#[deprecated(since = "1.0.0-alpha", note = "use `KeepRaw<'_, Header<'_>>` instead")] +pub type MintedHeader<'a> = KeepRaw<'a, Header<'a>>; pub use crate::alonzo::Multiasset; @@ -417,7 +417,7 @@ pub use crate::alonzo::AuxiliaryData; #[derive(Serialize, Encode, Decode, Debug, PartialEq, Clone)] pub struct Block<'b> { #[n(0)] - pub header: KeepRaw<'b, Header>, + pub header: KeepRaw<'b, Header<'b>>, #[b(1)] pub transaction_bodies: Vec>>, diff --git a/pallas-primitives/src/conway/model.rs b/pallas-primitives/src/conway/model.rs index 2d84fb862..c7ce37541 100644 --- a/pallas-primitives/src/conway/model.rs +++ b/pallas-primitives/src/conway/model.rs @@ -687,7 +687,7 @@ pub use crate::alonzo::AuxiliaryData; #[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Clone)] pub struct Block<'b> { #[n(0)] - pub header: KeepRaw<'b, Header>, + pub header: KeepRaw<'b, Header<'b>>, #[b(1)] pub transaction_bodies: Vec>>, diff --git a/pallas-traverse/src/hashes.rs b/pallas-traverse/src/hashes.rs index 5ba9c7131..5147cf57f 100644 --- a/pallas-traverse/src/hashes.rs +++ b/pallas-traverse/src/hashes.rs @@ -46,13 +46,13 @@ impl OriginalHash<32> for KeepRaw<'_, byron::Tx> { } } -impl ComputeHash<32> for alonzo::Header { +impl ComputeHash<32> for alonzo::Header<'_> { fn compute_hash(&self) -> pallas_crypto::hash::Hash<32> { Hasher::<256>::hash_cbor(self) } } -impl OriginalHash<32> for KeepRaw<'_, alonzo::Header> { +impl OriginalHash<32> for KeepRaw<'_, alonzo::Header<'_>> { fn original_hash(&self) -> pallas_crypto::hash::Hash<32> { Hasher::<256>::hash(self.raw_cbor()) } @@ -106,13 +106,13 @@ impl OriginalHash<32> for KeepRaw<'_, alonzo::TransactionBody> { } } -impl ComputeHash<32> for babbage::Header { +impl ComputeHash<32> for babbage::Header<'_> { fn compute_hash(&self) -> pallas_crypto::hash::Hash<32> { Hasher::<256>::hash_cbor(self) } } -impl OriginalHash<32> for KeepRaw<'_, babbage::Header> { +impl OriginalHash<32> for KeepRaw<'_, babbage::Header<'_>> { fn original_hash(&self) -> pallas_crypto::hash::Hash<32> { Hasher::<256>::hash(self.raw_cbor()) } diff --git a/pallas-traverse/src/lib.rs b/pallas-traverse/src/lib.rs index dec800acb..d3fd9f129 100644 --- a/pallas-traverse/src/lib.rs +++ b/pallas-traverse/src/lib.rs @@ -67,8 +67,8 @@ pub enum Feature { #[derive(Debug)] pub enum MultiEraHeader<'b> { EpochBoundary(Cow<'b, KeepRaw<'b, byron::EbbHead>>), - ShelleyCompatible(Cow<'b, KeepRaw<'b, alonzo::Header>>), - BabbageCompatible(Cow<'b, KeepRaw<'b, babbage::Header>>), + ShelleyCompatible(Cow<'b, KeepRaw<'b, alonzo::Header<'b>>>), + BabbageCompatible(Cow<'b, KeepRaw<'b, babbage::Header<'b>>>), Byron(Cow<'b, KeepRaw<'b, byron::BlockHead>>), }