Leaf

πŸ“– Definition:

A Leaf Node in the context of MPT is the terminal node in a tree, meaning it doesn't have any children. Instead of pointing to other nodes, it directly contains data or values.

πŸ“Œ Key Characteristics:

  1. Data Holder: A Leaf Node primarily encapsulates the data. In the context of MPT, it holds the value associated with a specific key

  2. No Children: As the name suggests, Leaf Nodes don’t have child nodes. They are the endpoints in the trie structure.

  3. Path Encoding: In MPT, if there's any remainder of the path leading to a Leaf Node, it's stored within the node itself

πŸ› οΈ Structure:

Representing the Leaf Node in Go, we utilize the following structure:

type LeafNode struct {
	Path  []nibble.Nibble
	Value []byte
	Dirty bool
}
  • Path: Represents the remaining segment of the path, stored as nibbles

  • Value: Holds the actual data or value associated with the key

  • Dirty: A flag indicating whether the node has been modified since the last commit

Last updated