Documentation ¶
Overview ¶
Package patricia computes the Merkle Patricia Tree Hash of a set of bit strings, as described in the Chain Protocol spec. See https://chain.com/docs/protocol/specifications/data#merkle-patricia-tree. Because a patricia tree (a radix tree with a radix of 2) provides efficient incremental updates, so does the Merkle Patricia Tree Hash computation, making this structure suitable for the blockchain full-state commitment.
Type Tree represents a set, where the elements are bit strings. The set must be prefix-free -- no item can be a prefix of any other -- enforced by Insert. The length of each bit string must also be a multiple of eight, because the interface uses []byte to represent an item.
The nodes in the tree form an immutable persistent data structure. It is okay to copy a Tree struct, which contains the root of the tree, to obtain a new tree with the same contents. The time to make such a copy is independent of the size of the tree.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree implements a patricia tree.