From fee59482f41245ebeada1aee9ccbdcb927c9bb67 Mon Sep 17 00:00:00 2001 From: Piotr Heilman Date: Thu, 24 Oct 2024 07:54:55 +0200 Subject: [PATCH] Allow only to update latest tree. --- src/identity_tree/mod.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/identity_tree/mod.rs b/src/identity_tree/mod.rs index acca0afd..ec56550a 100644 --- a/src/identity_tree/mod.rs +++ b/src/identity_tree/mod.rs @@ -399,8 +399,6 @@ impl> TreeVersion { /// all versions. This being a trait allows us to hide some of the /// implementation details. pub trait TreeVersionOps { - fn update(&self, leaf_index: usize, element: Hash); - /// Returns the current tree root. fn get_root(&self) -> Hash; /// Returns the next free leaf. @@ -417,10 +415,6 @@ impl TreeVersionOps for TreeVersion where TreeVersionData: BasicTreeOps, { - fn update(&self, leaf_index: usize, element: Hash) { - self.get_data().update(leaf_index, element); - } - fn get_root(&self) -> Hash { self.get_data().get_root() } @@ -456,6 +450,11 @@ impl TreeVersion { } impl TreeVersion { + /// Updates tree by inserting element at leaf index. + pub fn update(&self, leaf_index: usize, element: Hash) { + self.get_data().update(leaf_index, element); + } + /// Appends many identities to the tree, returns a list with the root, proof /// of inclusion and leaf index #[must_use]