merkle

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2019 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// There is not a root hash of empty merkle trie, so we use the hash of nil to represent it
	EmptyTrieHash = common.Sha3Nil
)

Functions

func Verify added in v1.2.0

func Verify(target common.Hash, root common.Hash, sibling []MerkleNode) bool

Verify verify the target node hash with sibling nodes and root

Types

type MerkleNode

type MerkleNode struct {
	Hash     common.Hash
	NodeType NodeTypeFlag
}

MerkleNode 用在获取与验证伴随节点

func FindSiblingNodes

func FindSiblingNodes(src common.Hash, srcNodes []common.Hash) ([]MerkleNode, error)

FindSiblingNodes 查找伴随节点

type MerkleTree

type MerkleTree struct {
	// contains filtered or unexported fields
}

func New

func New(leafHashes []common.Hash) *MerkleTree

New 新建一个merkle tree

func (*MerkleTree) HashNodes

func (m *MerkleTree) HashNodes() []common.Hash

HashNodes 获取所有的hash,从叶子节点到根root

func (*MerkleTree) Root

func (m *MerkleTree) Root() common.Hash

VersionRoot 获取根Hash

type NodeTypeFlag

type NodeTypeFlag int

NodeTypeFlag 节点类型标识

const (
	LeftNode NodeTypeFlag = iota
	RightNode
	RootNode
)

用在伴随节点

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL