//! Shared helpers for compact QMDB batches. use crate::{ merkle::{batch, compact, Family}, qmdb, Context, }; use commonware_codec::EncodeShared; use commonware_cryptography::Hasher; use commonware_parallel::Strategy; use std::sync::Arc; /// Encode operations, append them to a compact Merkle batch, and compute its root. pub(crate) fn merkleize_ops( merkle: &compact::Merkle, mut batch: compact::UnmerkleizedBatch, ops: &[Op], ) -> Arc> where F: Family, E: Context, H: Hasher, S: Strategy, Op: EncodeShared, { let hasher = qmdb::hasher::(); for op in ops { batch = batch.add(&hasher, &op.encode()); } merkle.with_mem(|mem| batch.merkleize(mem, &hasher)) }