[−][src]Struct starling::merkle_bit::MerkleBIT
The MerkleBIT
structure relies on many specified types:
Required Type Annotations
DatabaseType
: The type to use for database-like operations.DatabaseType
must implement theDatabase
trait.BranchType
: The type used for representing branches in the tree.BranchType
must implement theBranch
trait.LeafType
: The type used for representing leaves in the tree.LeafType
must implement theLeaf
trait.DataType
: The type used for representing data nodes in the tree.DataType
must implement theData
trait.NodeType
: The type used for the outer node that can be either a branch, leaf, or data.NodeType
must implement theNode
trait.HasherType
: The type of hasher to use for hashing locations on the tree.HasherType
must implement theHasher
trait.ValueType
: The type to return from a get.ValueType
must implement theEncode
andDecode
traits.ArrayType
: The type that stores the keys and hash results.ArrayType
must implement theArray
trait.
Properties
- db: The database to store and retrieve values.
- depth: The maximum permitted depth of the tree.
Implementations
impl<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> MerkleBIT<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> where
DatabaseType: Database<ArrayType, NodeType = NodeType>,
BranchType: Branch<ArrayType>,
LeafType: Leaf<ArrayType>,
DataType: Data,
NodeType: Node<BranchType, LeafType, DataType, ArrayType>,
HasherType: Hasher<ArrayType, HashType = HasherType>,
ValueType: Decode + Encode,
ArrayType: Array,
[src]
DatabaseType: Database<ArrayType, NodeType = NodeType>,
BranchType: Branch<ArrayType>,
LeafType: Leaf<ArrayType>,
DataType: Data,
NodeType: Node<BranchType, LeafType, DataType, ArrayType>,
HasherType: Hasher<ArrayType, HashType = HasherType>,
ValueType: Decode + Encode,
ArrayType: Array,
pub fn new(path: &PathBuf, depth: usize) -> BinaryMerkleTreeResult<Self>
[src]
pub fn from_db(db: DatabaseType, depth: usize) -> BinaryMerkleTreeResult<Self>
[src]
pub fn get(
&self,
root_hash: &ArrayType,
keys: &mut [ArrayType]
) -> BinaryMerkleTreeResult<HashMap<ArrayType, Option<ValueType>>>
[src]
&self,
root_hash: &ArrayType,
keys: &mut [ArrayType]
) -> BinaryMerkleTreeResult<HashMap<ArrayType, Option<ValueType>>>
Get items from the MerkleBIT
. Returns a map of Option
s which may include the corresponding values.
Errors
Exception
generated when an invalid state is encountered during tree traversal.
pub fn insert(
&mut self,
previous_root: Option<&ArrayType>,
keys: &mut [ArrayType],
values: &[ValueType]
) -> BinaryMerkleTreeResult<ArrayType>
[src]
&mut self,
previous_root: Option<&ArrayType>,
keys: &mut [ArrayType],
values: &[ValueType]
) -> BinaryMerkleTreeResult<ArrayType>
Insert items into the MerkleBIT
. Keys must be sorted. Returns a new root hash for the MerkleBIT
.
Errors
Exception
generated if an invalid state is encountered during tree traversal.
pub fn remove(&mut self, root_hash: &ArrayType) -> BinaryMerkleTreeResult<()>
[src]
Remove all items with less than 1 reference under the given root.
Errors
Exception
generated when an invalid state is encountered during tree traversal.
pub fn generate_inclusion_proof(
&self,
root: &ArrayType,
key: ArrayType
) -> BinaryMerkleTreeResult<Vec<(ArrayType, bool)>>
[src]
&self,
root: &ArrayType,
key: ArrayType
) -> BinaryMerkleTreeResult<Vec<(ArrayType, bool)>>
Generates an inclusion proof. The proof consists of a list of hashes beginning with the key/value pair and traveling up the tree until the level below the root is reached.
Errors
Exception
generated when an invalid state is encountered during tree traversal.
pub fn verify_inclusion_proof(
root: &ArrayType,
key: ArrayType,
value: &ValueType,
proof: &[(ArrayType, bool)]
) -> BinaryMerkleTreeResult<()>
[src]
root: &ArrayType,
key: ArrayType,
value: &ValueType,
proof: &[(ArrayType, bool)]
) -> BinaryMerkleTreeResult<()>
pub fn get_one(
&self,
root: &ArrayType,
key: &ArrayType
) -> BinaryMerkleTreeResult<Option<ValueType>>
[src]
&self,
root: &ArrayType,
key: &ArrayType
) -> BinaryMerkleTreeResult<Option<ValueType>>
Gets a single key from the tree.
Errors
Exception
generated from encountering an invalid state during tree traversal.
pub fn insert_one(
&mut self,
previous_root: Option<&ArrayType>,
key: &ArrayType,
value: &ValueType
) -> BinaryMerkleTreeResult<ArrayType>
[src]
&mut self,
previous_root: Option<&ArrayType>,
key: &ArrayType,
value: &ValueType
) -> BinaryMerkleTreeResult<ArrayType>
Inserts a single value into a tree.
Errors
Exception
generated if an invalid state is encountered during tree traversal.
Auto Trait Implementations
impl<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> RefUnwindSafe for MerkleBIT<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> where
ArrayType: RefUnwindSafe,
BranchType: RefUnwindSafe,
DataType: RefUnwindSafe,
DatabaseType: RefUnwindSafe,
HasherType: RefUnwindSafe,
LeafType: RefUnwindSafe,
NodeType: RefUnwindSafe,
ValueType: RefUnwindSafe,
ArrayType: RefUnwindSafe,
BranchType: RefUnwindSafe,
DataType: RefUnwindSafe,
DatabaseType: RefUnwindSafe,
HasherType: RefUnwindSafe,
LeafType: RefUnwindSafe,
NodeType: RefUnwindSafe,
ValueType: RefUnwindSafe,
impl<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> Send for MerkleBIT<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> where
ArrayType: Send,
BranchType: Send,
DataType: Send,
DatabaseType: Send,
HasherType: Send,
LeafType: Send,
NodeType: Send,
ValueType: Send,
ArrayType: Send,
BranchType: Send,
DataType: Send,
DatabaseType: Send,
HasherType: Send,
LeafType: Send,
NodeType: Send,
ValueType: Send,
impl<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> Sync for MerkleBIT<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> where
ArrayType: Sync,
BranchType: Sync,
DataType: Sync,
DatabaseType: Sync,
HasherType: Sync,
LeafType: Sync,
NodeType: Sync,
ValueType: Sync,
ArrayType: Sync,
BranchType: Sync,
DataType: Sync,
DatabaseType: Sync,
HasherType: Sync,
LeafType: Sync,
NodeType: Sync,
ValueType: Sync,
impl<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> Unpin for MerkleBIT<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> where
ArrayType: Unpin,
BranchType: Unpin,
DataType: Unpin,
DatabaseType: Unpin,
HasherType: Unpin,
LeafType: Unpin,
NodeType: Unpin,
ValueType: Unpin,
ArrayType: Unpin,
BranchType: Unpin,
DataType: Unpin,
DatabaseType: Unpin,
HasherType: Unpin,
LeafType: Unpin,
NodeType: Unpin,
ValueType: Unpin,
impl<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> UnwindSafe for MerkleBIT<DatabaseType, BranchType, LeafType, DataType, NodeType, HasherType, ValueType, ArrayType> where
ArrayType: UnwindSafe,
BranchType: UnwindSafe,
DataType: UnwindSafe,
DatabaseType: UnwindSafe,
HasherType: UnwindSafe,
LeafType: UnwindSafe,
NodeType: UnwindSafe,
ValueType: UnwindSafe,
ArrayType: UnwindSafe,
BranchType: UnwindSafe,
DataType: UnwindSafe,
DatabaseType: UnwindSafe,
HasherType: UnwindSafe,
LeafType: UnwindSafe,
NodeType: UnwindSafe,
ValueType: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,