make PrecomputedSubtrees more generic
This commit is contained in:
parent
d4e504aac8
commit
f51694835a
1 changed files with 6 additions and 6 deletions
|
@ -352,8 +352,8 @@ pub(crate) trait SparseMerkleTree<const DEPTH: u8> {
|
|||
|
||||
fn sorted_pairs_to_leaves(
|
||||
pairs: Vec<(Self::Key, Self::Value)>,
|
||||
) -> PrecomputedSubtrees<Self::Leaf> {
|
||||
let mut accumulator: PrecomputedSubtrees<Self::Leaf> = Default::default();
|
||||
) -> PrecomputedSubtrees<u64, Self::Leaf> {
|
||||
let mut accumulator: PrecomputedSubtrees<u64, Self::Leaf> = Default::default();
|
||||
|
||||
// The kv-pairs we've seen so far that correspond to a single leaf.
|
||||
let mut current_leaf_buffer: Vec<(Self::Key, Self::Value)> = Default::default();
|
||||
|
@ -632,14 +632,14 @@ impl SubtreeLeaf {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct PrecomputedSubtrees<L> {
|
||||
pub struct PrecomputedSubtrees<K, L> {
|
||||
/// Literal leaves to be added to the sparse Merkle tree's internal mapping.
|
||||
pub nodes: BTreeMap<u64, L>,
|
||||
pub nodes: BTreeMap<K, L>,
|
||||
/// "Conceptual" leaves that will be used for computations.
|
||||
pub leaves: Vec<Vec<SubtreeLeaf>>,
|
||||
}
|
||||
|
||||
impl<L> PrecomputedSubtrees<L> {
|
||||
impl<K, L> PrecomputedSubtrees<K, L> {
|
||||
pub fn add_leaf(&mut self, leaf: SubtreeLeaf) {
|
||||
let last_subtree = match self.leaves.last_mut() {
|
||||
// Base case.
|
||||
|
@ -670,7 +670,7 @@ impl<L> PrecomputedSubtrees<L> {
|
|||
}
|
||||
|
||||
// Derive requires `L` to impl Default, even though we don't actually need that.
|
||||
impl<L> Default for PrecomputedSubtrees<L> {
|
||||
impl<K, L> Default for PrecomputedSubtrees<K, L> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
nodes: Default::default(),
|
||||
|
|
Loading…
Add table
Reference in a new issue