From 37f0c7893117b2058fbade9fb32b9c82932c18eb Mon Sep 17 00:00:00 2001 From: seemenkina Date: Fri, 17 May 2024 15:53:50 +0700 Subject: [PATCH] add constructor --- src/tree.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tree.rs b/src/tree.rs index cc686af..9b8ee8c 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -21,6 +21,12 @@ impl From for DBKey { } } +impl Key { + pub fn new(depth: usize, index: usize) -> Self { + Key(depth, index) + } +} + /// The Merkle Tree structure pub struct MerkleTree where @@ -89,7 +95,7 @@ where // Load existing db instance let db = D::load(db_config)?; - // Load root + // Load root let root = match db.get(Key(0, 0).into())? { Some(root) => H::deserialize(root), None => H::default_leaf(), @@ -98,7 +104,7 @@ where // Load depth & next_index values from db let depth = match db.get(DEPTH_KEY)? { Some(depth) => usize::from_be_bytes(depth.try_into().unwrap()), - None => 20 + None => 20, }; let next_index = match db.get(NEXT_INDEX_KEY)? {