pub struct TreeNode {
pub label: NodeLabel,
pub last_epoch: u64,
pub least_descendant_ep: u64,
pub parent: NodeLabel,
pub node_type: NodeType,
pub left_child: Option<NodeLabel>,
pub right_child: Option<NodeLabel>,
pub hash: [u8; 32],
}
Expand description
A TreeNode represents a generic node of a Merkle Patricia Trei with ordering. The main idea here is that the tree is changing at every epoch and that we do not need to touch the state of a node, unless it changes. The leaves of the tree represented by these nodes is supposed to allow for a user to monitor the state of a key-value pair in the past. We achieve this by including the epoch a leaf was added as part of the hash stored in it. At a later time, we may need to access older sub-trees of the tree built with these nodes. To facilitate this, we require this struct to include the last time a node was updated as well as the oldest descendant it holds.
Fields
label: NodeLabel
The binary label for this node
last_epoch: u64
The last epoch this node was updated in
least_descendant_ep: u64
The least epoch of any descendant of this node
parent: NodeLabel
The label of this node’s parent
node_type: NodeType
The type of node: leaf, root or interior.
left_child: Option<NodeLabel>
Label of the left child, None if there is none.
right_child: Option<NodeLabel>
Label of the right child, None if there is none.
hash: [u8; 32]
Hash (aka state) of the node.
Trait Implementations
sourceimpl PartialEq<TreeNode> for TreeNode
impl PartialEq<TreeNode> for TreeNode
impl Eq for TreeNode
impl StructuralEq for TreeNode
impl StructuralPartialEq for TreeNode
impl Sync for TreeNode
Auto Trait Implementations
impl RefUnwindSafe for TreeNode
impl Send for TreeNode
impl Unpin for TreeNode
impl UnwindSafe for TreeNode
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.