mavl

package
v0.0.0-...-9259d71 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNodeNotExist node is not exist
	ErrNodeNotExist = errors.New("ErrNodeNotExist")
)

Functions

func ClosePrune

func ClosePrune()

ClosePrune 关闭裁剪

func DelKVPair

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

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

func EnableMVCC

func EnableMVCC(enable bool)

EnableMVCC 使能MVCC

func EnableMavlPrefix

func EnableMavlPrefix(enable bool)

EnableMavlPrefix 使能mavl加前缀

func EnablePrune

func EnablePrune(enable bool)

EnablePrune 使能裁剪

func GetKVPair

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

GetKVPair 获取kv对外接口

func GetKVPairProof

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

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

func InnerNodeProofHash

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

InnerNodeProofHash 计算inner节点的hash

func IterateRangeByStateHash

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

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

func PrintNode

func PrintNode(node *Node)

PrintNode the in-memory children recursively.

func PrintTreeLeaf

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

PrintTreeLeaf 通过roothash打印所有叶子节点

func PruningTree

func PruningTree(db dbm.DB, curHeight int64)

PruningTree 裁剪树

func PruningTreePrintDB

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

PruningTreePrintDB 打印统计数据库中节点数据

func SetKVPair

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

SetKVPair 设置kv对外接口

func SetPruneHeight

func SetPruneHeight(height int)

SetPruneHeight 设置每次裁剪高度

func VerifyKVPairProof

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

VerifyKVPairProof 验证KVPair 的证明

Types

type MarkNode

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

MarkNode 用于裁剪的节点结构体

type Node

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

Node merkle avl Node

func MakeNode

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

MakeNode 从数据库中读取数据,创建Node 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

NewNode 创建节点;保存数据的是叶子节点

func (*Node) Hash

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

Hash 计算节点的hash

type Proof

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

Proof 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

Root 证明节点的root hash

func (*Proof) Verify

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

Verify key:value 的proof确认

type Tree

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

Tree merkle avl tree

func NewTree

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

NewTree 新建一个merkle avl 树

func (*Tree) ConstructProof

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

ConstructProof Returns nil, nil if key is not in tree.

func (*Tree) Copy

func (t *Tree) Copy() *Tree

Copy copy tree

func (*Tree) Get

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

Get 通过key获取leaf节点信息

func (*Tree) GetByIndex

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

GetByIndex 通过index获取leaf节点信息

func (*Tree) Has

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

Has 判断key是否存在tree中

func (*Tree) Hash

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

Hash 计算tree 的roothash

func (*Tree) Height

func (t *Tree) Height() int32

Height 获取tree的高度

func (*Tree) Iterate

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

Iterate 依次迭代遍历树的所有键

func (*Tree) IterateRange

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

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

func (*Tree) IterateRangeInclusive

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

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

func (*Tree) Load

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

Load 从db中加载rootnode

func (*Tree) Proof

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

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

func (*Tree) Remove

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

Remove 删除key对应的节点

func (*Tree) Save

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

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

func (*Tree) Set

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

Set 设置k:v pair到tree中

func (*Tree) SetBlockHeight

func (t *Tree) SetBlockHeight(height int64)

SetBlockHeight 设置block高度到tree

func (*Tree) Size

func (t *Tree) Size() int32

Size 获取tree的叶子节点数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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