mavl

package
v0.0.0-...-1c4572a Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNodeNotExist = errors.New("ErrNodeNotExist")
)

Functions

func ClosePrune

func ClosePrune()

func DelKVPair

func DelKVPair(db dbm.DB, storeDel *types.StoreGet) ([]byte, [][]byte, error)

剔除key对应的节点在本次tree中,返回新的roothash和key对应的value

func EnableMVCC

func EnableMVCC(enable bool)

func EnableMavlPrefix

func EnableMavlPrefix(enable bool)

func EnablePrune

func EnablePrune(enable bool)

func GetKVPair

func GetKVPair(db dbm.DB, storeGet *types.StoreGet) ([][]byte, error)

func GetKVPairProof

func GetKVPairProof(db dbm.DB, roothash []byte, key []byte) ([]byte, error)

func InnerNodeProofHash

func InnerNodeProofHash(childHash []byte, branch *types.InnerNode) []byte

计算inner节点的hash

func IterateRangeByStateHash

func IterateRangeByStateHash(db dbm.DB, statehash, start, end []byte, ascending bool, fn func([]byte, []byte) bool)

func NewDelNodeValuePool

func NewDelNodeValuePool(cacSize int) *delNodeValuePool

func PrintNode

func PrintNode(node *Node)

Prints the in-memory children recursively.

func PrintTreeLeaf

func PrintTreeLeaf(db dbm.DB, roothash []byte)

func PruningTree

func PruningTree(db dbm.DB, curHeight int64)

func PruningTreePrintDB

func PruningTreePrintDB(db dbm.DB, prefix []byte)

func SetKVPair

func SetKVPair(db dbm.DB, storeSet *types.StoreSet, sync bool) ([]byte, error)

对外接口

func SetPruneHeight

func SetPruneHeight(height int)

func VerifyKVPairProof

func VerifyKVPairProof(db dbm.DB, roothash []byte, keyvalue types.KeyValue, proof []byte) bool

Types

type MarkNode

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

type Node

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

merkle avl Node

func MakeNode

func MakeNode(buf []byte, t *Tree) (node *Node, err error)

NOTE: The hash is not saved or set. The caller should set the hash afterwards. (Presumably the caller already has the hash)

func NewNode

func NewNode(key []byte, value []byte) *Node

保存数据的是叶子节点

func (*Node) Hash

func (node *Node) Hash(t *Tree) []byte

计算节点的hash

type Proof

type Proof struct {
	LeafHash   []byte
	InnerNodes []*types.InnerNode
	RootHash   []byte
}

merkle avl tree proof证明结构体

func ReadProof

func ReadProof(roothash []byte, leafhash []byte, data []byte) (*Proof, error)

ReadProof will deserialize a MAVLProof from bytes

func (*Proof) Root

func (proof *Proof) Root() []byte

func (*Proof) Verify

func (proof *Proof) Verify(key []byte, value []byte, root []byte) bool

key:value 的proof确认

type Tree

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

merkle avl tree

func NewTree

func NewTree(db dbm.DB, sync bool) *Tree

新建一个merkle avl 树

func (*Tree) ConstructProof

func (t *Tree) ConstructProof(key []byte) (value []byte, proof *Proof)

Returns nil, nil if key is not in tree.

func (*Tree) Copy

func (t *Tree) Copy() *Tree

func (*Tree) Get

func (t *Tree) Get(key []byte) (index int32, value []byte, exists bool)

通过key获取leaf节点信息

func (*Tree) GetByIndex

func (t *Tree) GetByIndex(index int32) (key []byte, value []byte)

通过index获取leaf节点信息

func (*Tree) Has

func (t *Tree) Has(key []byte) bool

判断key是否存在tree中

func (*Tree) Hash

func (t *Tree) Hash() []byte

计算tree 的roothash

func (*Tree) Height

func (t *Tree) Height() int32

获取tree的高度

func (*Tree) Iterate

func (t *Tree) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)

依次迭代遍历树的所有键

func (*Tree) IterateRange

func (t *Tree) IterateRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) (stopped bool)

在start和end之间的键进行迭代回调[start, end)

func (*Tree) IterateRangeInclusive

func (t *Tree) IterateRangeInclusive(start, end []byte, ascending bool, fn func(key, value []byte) bool) (stopped bool)

在start和end之间的键进行迭代回调[start, end]

func (*Tree) Load

func (t *Tree) Load(hash []byte) (err error)

从db中加载rootnode

func (*Tree) Proof

func (t *Tree) Proof(key []byte) (value []byte, proofBytes []byte, exists bool)

获取指定k:v pair的proof证明

func (*Tree) Remove

func (t *Tree) Remove(key []byte) (value []byte, removed bool)

删除key对应的节点

func (*Tree) Save

func (t *Tree) Save() []byte

保存整个tree的节点信息到db中

func (*Tree) Set

func (t *Tree) Set(key []byte, value []byte) (updated bool)

设置k:v pair到tree中

func (*Tree) SetBlockHeight

func (t *Tree) SetBlockHeight(height int64)

func (*Tree) Size

func (t *Tree) Size() int32

获取tree的叶子节点数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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