mirror of
https://github.com/vacp2p/pmtree.git
synced 2025-02-22 20:18:21 +00:00
add constructor
This commit is contained in:
parent
720079efb2
commit
37f0c78931
@ -21,6 +21,12 @@ impl From<Key> for DBKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Key {
|
||||||
|
pub fn new(depth: usize, index: usize) -> Self {
|
||||||
|
Key(depth, index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The Merkle Tree structure
|
/// The Merkle Tree structure
|
||||||
pub struct MerkleTree<D, H>
|
pub struct MerkleTree<D, H>
|
||||||
where
|
where
|
||||||
@ -98,7 +104,7 @@ where
|
|||||||
// Load depth & next_index values from db
|
// Load depth & next_index values from db
|
||||||
let depth = match db.get(DEPTH_KEY)? {
|
let depth = match db.get(DEPTH_KEY)? {
|
||||||
Some(depth) => usize::from_be_bytes(depth.try_into().unwrap()),
|
Some(depth) => usize::from_be_bytes(depth.try_into().unwrap()),
|
||||||
None => 20
|
None => 20,
|
||||||
};
|
};
|
||||||
|
|
||||||
let next_index = match db.get(NEXT_INDEX_KEY)? {
|
let next_index = match db.get(NEXT_INDEX_KEY)? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user