Documentation
¶
Index ¶
- Constants
- Variables
- type Node
- type Tree
- func (t *Tree) BuildMerkleProofs(index int64) (rMerkleProof [][]byte, rProofHelper []int, err error)
- func (t *Tree) BuildTree(nodes []*Node) (err error)
- func (t *Tree) HashSubTrees(l []byte, r []byte) []byte
- func (t *Tree) InitNilHashValueConst() (err error)
- func (t *Tree) IsEmptyTree() bool
- func (t *Tree) Update(index int64, nVal []byte) (err error)
- func (t *Tree) VerifyMerkleProofs(inclusionProofs [][]byte, helperProofs []int) bool
Constants ¶
View Source
const ( Left = 0 Right = 1 )
Variables ¶
View Source
var (
NilHash = common.FromHex("01ef55cdf3b9b0d65e6fb6317f79627534d971fd96c811281af618c0028d5e7a")
)
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { // node value Value []byte // left node Left *Node // right node Right *Node // parent node Parent *Node // height Height int }
Node: node in the tree
func CreateLeafNode ¶
func CreateLeaves ¶
CreateLeaves: transfer hashState to []node @hashState: hash state
type Tree ¶
type Tree struct { // root Node RootNode *Node // leaves Leaves []*Node // max height MaxHeight int // nil hash tree NilHashValueConst [][]byte // hash function HashFunc hash.Hash }
Tree: sparse merkle tree
func NewEmptyTree ¶
func NewTree ¶
func: NewTree params: leaves []*Node, maxHeight int, nilHash []byte, hFunc hash.Hash desp: Use leaf nodes to initialize the tree, and call the BuildTree method through the root to initialize the hash value of the entire tree
func NewTreeByMap ¶
func NewTreeByMap(leaves map[int64]*Node, maxHeight int, nilHash []byte, hFunc hash.Hash) (*Tree, error)
func: NewTree params: leaves []*Node, maxHeight int, nilHash []byte, hFunc hash.Hash desp: Use leaf nodes to initialize the tree, and call the BuildTree method through the root to initialize the hash value of the entire tree
func (*Tree) BuildMerkleProofs ¶
func (t *Tree) BuildMerkleProofs(index int64) ( rMerkleProof [][]byte, rProofHelper []int, err error, )
BuildMerkleProofs: construct merkle proofs
func (*Tree) HashSubTrees ¶
HashSubTrees: hash sub-tree nodes
func (*Tree) InitNilHashValueConst ¶
func (*Tree) IsEmptyTree ¶
Click to show internal directories.
Click to hide internal directories.