diff --git a/sequencer/src/block2.rs b/sequencer/src/block2.rs index 44c2ea9d99..00e6e676bf 100644 --- a/sequencer/src/block2.rs +++ b/sequencer/src/block2.rs @@ -12,7 +12,7 @@ mod tables; pub mod tx_iterator; use crate::block2::entry::TxTableEntryWord; -use crate::block2::payload::NameSpaceTable; +use crate::block2::tables::NameSpaceTable; use payload::Payload; impl BlockPayload for Payload { diff --git a/sequencer/src/block2/payload.rs b/sequencer/src/block2/payload.rs index 22b8873e07..53b7c0852a 100644 --- a/sequencer/src/block2/payload.rs +++ b/sequencer/src/block2/payload.rs @@ -14,10 +14,10 @@ use num_traits::PrimInt; use serde::{Deserialize, Serialize}; use snafu::OptionExt; use std::default::Default; -use std::marker::PhantomData; use std::sync::OnceLock; use std::{collections::HashMap, fmt::Display, ops::Range}; +use crate::block2::tables::NameSpaceTable; use trait_set::trait_set; trait_set! { @@ -59,23 +59,15 @@ pub(super) struct NamespaceInfo { pub(crate) tx_table_len: TxTableEntry, } -#[derive(Clone, Debug, Derivative, Deserialize, Eq, Serialize, Default)] -#[derivative(Hash, PartialEq)] -// TODO store only a reference to raw_payload. -pub struct NameSpaceTable { - pub(crate) raw_payload: Vec, - pub phantom: PhantomData, -} - #[allow(dead_code)] // TODO temporary #[derive(Clone, Debug, Derivative, Deserialize, Eq, Serialize)] #[derivative(Hash, PartialEq)] -pub struct Payload { +pub(super) struct Payload { // Sequence of bytes representing the concatenated payloads for each namespace pub(super) raw_payload: Vec, // Sequence of bytes representing the namespace table - pub ns_table: NameSpaceTable, + pub(super) ns_table: NameSpaceTable, // cache frequently used items // @@ -868,8 +860,8 @@ mod test { mod helpers { use crate::block2::entry::TxTableEntry; - use crate::block2::payload::{NameSpaceTable, TableWordTraits}; - use crate::block2::tables::{Table, TxTableTest}; + use crate::block2::payload::TableWordTraits; + use crate::block2::tables::{NameSpaceTable, Table, TxTableTest}; use crate::VmId; use rand::RngCore; diff --git a/sequencer/src/block2/queryable.rs b/sequencer/src/block2/queryable.rs index c939a20b63..3ec7b1b837 100644 --- a/sequencer/src/block2/queryable.rs +++ b/sequencer/src/block2/queryable.rs @@ -1,6 +1,6 @@ use crate::block2::entry::TxTableEntryWord; -use crate::block2::payload::{test_vid_factory, NameSpaceTable, Payload, RangeProof}; -use crate::block2::tables::TxTable; +use crate::block2::payload::{test_vid_factory, Payload, RangeProof}; +use crate::block2::tables::{NameSpaceTable, TxTable}; use hotshot_query_service::availability::QueryablePayload; use jf_primitives::vid::payload_prover::{PayloadProver, Statement}; use serde::{Deserialize, Serialize}; diff --git a/sequencer/src/block2/tables.rs b/sequencer/src/block2/tables.rs index 06fa2c0cf0..8b1663e860 100644 --- a/sequencer/src/block2/tables.rs +++ b/sequencer/src/block2/tables.rs @@ -1,6 +1,8 @@ use crate::block2::entry::TxTableEntry; -use crate::block2::payload::{NameSpaceTable, Payload, TableWordTraits}; +use crate::block2::payload::{Payload, TableWordTraits}; use crate::{BlockBuildingSnafu, Error, VmId}; +use derivative::Derivative; +use serde::{Deserialize, Serialize}; use snafu::OptionExt; use std::marker::PhantomData; use std::mem::size_of; @@ -40,6 +42,14 @@ impl Table for NameSpaceTable } } +#[derive(Clone, Debug, Derivative, Deserialize, Eq, Serialize, Default)] +#[derivative(Hash, PartialEq)] +// TODO store only a reference to raw_payload. +pub(super) struct NameSpaceTable { + pub(super) raw_payload: Vec, + pub(super) phantom: PhantomData, +} + impl NameSpaceTable { pub fn from_vec(v: Vec) -> Self { Self { diff --git a/sequencer/src/block2/tx_iterator.rs b/sequencer/src/block2/tx_iterator.rs index eb88825be3..8714fbdda6 100644 --- a/sequencer/src/block2/tx_iterator.rs +++ b/sequencer/src/block2/tx_iterator.rs @@ -1,7 +1,7 @@ use std::ops::Range; -use crate::block2::payload::{NameSpaceTable, Payload, TableWordTraits}; -use crate::block2::tables::TxTable; +use crate::block2::payload::{Payload, TableWordTraits}; +use crate::block2::tables::{NameSpaceTable, TxTable}; use serde::{Deserialize, Serialize}; /// TODO do we really need `PartialOrd`, `Ord` here? @@ -21,7 +21,10 @@ pub struct TxIterator<'a, TableWord: TableWordTraits> { } impl<'a, TableWord: TableWordTraits> TxIterator<'a, TableWord> { - pub fn new(ns_table: NameSpaceTable, block_payload: &'a Payload) -> Self { + pub(super) fn new( + ns_table: NameSpaceTable, + block_payload: &'a Payload, + ) -> Self { Self { ns_idx: 0, // arbitrary value, changed in first call to next() ns_iter: 0..ns_table.len(),