Skip to content

Commit

Permalink
derive BFieldCodec for MutatorSetAccumulator
Browse files Browse the repository at this point in the history
  • Loading branch information
aszepieniec committed Jul 25, 2023
1 parent 8ee3465 commit b858bd8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/util_types/mutator_set/active_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use super::shared::{CHUNK_SIZE, WINDOW_SIZE};
pub struct ActiveWindow<H: AlgebraicHasher + BFieldCodec> {
// It's OK to store this in memory, since it's on the size of kilobytes, not gigabytes.
pub sbf: Vec<u32>,
#[bfield_codec(ignore)]
_hasher: PhantomData<H>,
}

Expand Down
19 changes: 1 addition & 18 deletions src/util_types/mutator_set/mutator_set_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{
mutator_set_trait::MutatorSet, removal_record::RemovalRecord,
};

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, GetSize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, GetSize, BFieldCodec)]
pub struct MutatorSetAccumulator<H: AlgebraicHasher + BFieldCodec> {
pub kernel: MutatorSetKernel<H, MmrAccumulator<H>>,
}
Expand Down Expand Up @@ -95,23 +95,6 @@ impl<H: AlgebraicHasher + BFieldCodec> MutatorSet<H> for MutatorSetAccumulator<H
}
}

impl<H: AlgebraicHasher + BFieldCodec> BFieldCodec for MutatorSetAccumulator<H> {
fn decode(
sequence: &[twenty_first::shared_math::b_field_element::BFieldElement],
) -> anyhow::Result<Box<Self>> {
let kernel = *MutatorSetKernel::decode(sequence)?;
Ok(Box::new(Self { kernel }))
}

fn encode(&self) -> Vec<twenty_first::shared_math::b_field_element::BFieldElement> {
self.kernel.encode()
}

fn static_length() -> Option<usize> {
None
}
}

#[cfg(test)]
mod ms_accumulator_tests {
use crate::util_types::test_shared::mutator_set::*;
Expand Down

0 comments on commit b858bd8

Please sign in to comment.