From df118be7c57b57a12f310caf5f96037925b3b8c2 Mon Sep 17 00:00:00 2001 From: Marcin Wajdzik Date: Tue, 27 Aug 2024 15:57:50 +0200 Subject: [PATCH] 0.4.6 feat: added leaf_count_to_mmr_size --- Cargo.toml | 2 +- src/mmr/helpers.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4843222..182f193 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "accumulators" -version = "0.4.5" +version = "0.4.6" edition = "2021" license-file = "LICENSE" description = "Complete package of multiple Accumulators with Stores and hashing functions (Hashers)" diff --git a/src/mmr/helpers.rs b/src/mmr/helpers.rs index 6fef9f5..f595927 100644 --- a/src/mmr/helpers.rs +++ b/src/mmr/helpers.rs @@ -135,6 +135,10 @@ pub fn leaf_count_to_peaks_count(leaf_count: usize) -> u32 { count_ones(leaf_count) as u32 } +pub fn leaf_count_to_mmr_size(leaf_count: usize) -> usize { + 2 * leaf_count - leaf_count_to_peaks_count(leaf_count) as usize +} + pub fn leaf_count_to_append_no_merges(leaf_count: usize) -> usize { count_trailing_ones(leaf_count) }