Skip to content

Commit

Permalink
Add function to init tree
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienFT committed Mar 14, 2024
1 parent 0af9411 commit 27d4178
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ where
Ok(Self { tries })
}

/// Initialize a new trie with the given identifier.
/// This function is useful when you want to create a new trie in the database without inserting any value.
/// If the trie already exists, it will do nothing.
/// When you insert a value in a trie, it will automatically create the trie if it doesn't exist.
pub fn init_tree(
&mut self,
identifier: &[u8],
) -> Result<(), BonsaiStorageError<DB::DatabaseError>> {
self.tries.init_tree(identifier)
}

/// Insert a new key/value in the trie, overwriting the previous value if it exists.
/// If the value already exists it will overwrite it.
pub fn insert(
Expand Down

0 comments on commit 27d4178

Please sign in to comment.