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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.