*: apply go 1.19 formatter heuristics
And make manual corrections where needed. See the "Common mistakes and pitfalls" section of https://tip.golang.org/doc/comment.
This commit is contained in:
parent
bb751535d3
commit
916f2293b8
20 changed files with 167 additions and 150 deletions
|
@ -4,11 +4,11 @@ Package mpt implements MPT (Merkle-Patricia Trie).
|
|||
An MPT stores key-value pairs and is a trie over 16-symbol alphabet. https://en.wikipedia.org/wiki/Trie
|
||||
A trie is a tree where values are stored in leafs and keys are paths from the root to the leaf node.
|
||||
An MPT consists of 4 types of nodes:
|
||||
- Leaf node only contains a value.
|
||||
- Extension node contains both a key and a value.
|
||||
- Branch node contains 2 or more children.
|
||||
- Hash node is a compressed node and only contains the actual node's hash.
|
||||
The actual node must be retrieved from the storage or over the network.
|
||||
- Leaf node only contains a value.
|
||||
- Extension node contains both a key and a value.
|
||||
- Branch node contains 2 or more children.
|
||||
- Hash node is a compressed node and only contains the actual node's hash.
|
||||
The actual node must be retrieved from the storage or over the network.
|
||||
|
||||
As an example here is a trie containing 3 pairs:
|
||||
- 0x1201 -> val1
|
||||
|
@ -16,18 +16,18 @@ As an example here is a trie containing 3 pairs:
|
|||
- 0x1224 -> val3
|
||||
- 0x12 -> val4
|
||||
|
||||
ExtensionNode(0x0102), Next
|
||||
_______________________|
|
||||
|
|
||||
BranchNode [0, 1, 2, ...], Last -> Leaf(val4)
|
||||
| |
|
||||
| ExtensionNode [0x04], Next -> Leaf(val3)
|
||||
|
|
||||
BranchNode [0, 1, 2, 3, ...], Last -> HashNode(nil)
|
||||
| |
|
||||
| Leaf(val2)
|
||||
|
|
||||
Leaf(val1)
|
||||
ExtensionNode(0x0102), Next
|
||||
_______________________|
|
||||
|
|
||||
BranchNode [0, 1, 2, ...], Last -> Leaf(val4)
|
||||
| |
|
||||
| ExtensionNode [0x04], Next -> Leaf(val3)
|
||||
|
|
||||
BranchNode [0, 1, 2, 3, ...], Last -> HashNode(nil)
|
||||
| |
|
||||
| Leaf(val2)
|
||||
|
|
||||
Leaf(val1)
|
||||
|
||||
There are 3 invariants that this implementation has:
|
||||
- Branch node cannot have <= 1 children
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue