Documentation ¶
Overview ¶
Package mavl 默克尔平衡树算法实现以及裁剪
Index ¶
- Constants
- Variables
- func ClosePrune()
- func DelKVPair(db dbm.DB, storeDel *types.StoreGet, treeCfg *TreeConfig) ([]byte, [][]byte, error)
- func DelLeafCountKV(db dbm.DB, blockHeight int64, treeCfg *TreeConfig) error
- func GetKVPair(db dbm.DB, storeGet *types.StoreGet, treeCfg *TreeConfig) ([][]byte, error)
- func GetKVPairProof(db dbm.DB, roothash []byte, key []byte, treeCfg *TreeConfig) ([]byte, error)
- func InitGlobalMem(treeCfg *TreeConfig)
- func InnerNodeProofHash(childHash []byte, branch *types.InnerNode) []byte
- func IterateRangeByStateHash(db dbm.DB, statehash, start, end []byte, ascending bool, treeCfg *TreeConfig, ...)
- func LoadTree2MemDb(db dbm.DB, hash []byte, mp map[uint64]struct{})
- func PrintLeafNodeParent(db dbm.DB, key, hash []byte, height int64)
- func PrintMemStats(height int64)
- func PrintNode(node *Node)
- func PrintNodeDb(db dbm.DB, hash []byte)
- func PrintSameLeafKey(db dbm.DB, key string)
- func PrintTreeLeaf(db dbm.DB, roothash []byte, treeCfg *TreeConfig)
- func PruningTree(db dbm.DB, curHeight int64, treeCfg *TreeConfig)
- func PruningTreePrintDB(db dbm.DB, prefix []byte)
- func ReleaseGlobalMem()
- func SetKVPair(db dbm.DB, storeSet *types.StoreSet, sync bool, treeCfg *TreeConfig) ([]byte, error)
- func VerifyKVPairProof(db dbm.DB, roothash []byte, keyvalue types.KeyValue, proof []byte) bool
- type MemTreeOpera
- type Node
- type Proof
- type Tree
- func (t *Tree) ConstructProof(key []byte) (value []byte, proof *Proof)
- func (t *Tree) Copy() *Tree
- func (t *Tree) Get(key []byte) (index int32, value []byte, exists bool)
- func (t *Tree) GetByIndex(index int32) (key []byte, value []byte)
- func (t *Tree) GetHash(key []byte) (index int32, hash []byte, exists bool)
- func (t *Tree) Has(key []byte) bool
- func (t *Tree) Hash() []byte
- func (t *Tree) Height() int32
- func (t *Tree) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
- func (t *Tree) IterateRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) (stopped bool)
- func (t *Tree) IterateRangeInclusive(start, end []byte, ascending bool, fn func(key, value []byte) bool) (stopped bool)
- func (t *Tree) Load(hash []byte) (err error)
- func (t *Tree) Proof(key []byte) (value []byte, proofBytes []byte, exists bool)
- func (t *Tree) Remove(key []byte) (value []byte, removed bool)
- func (t *Tree) RemoveLeafCountKey(height int64)
- func (t *Tree) Save() []byte
- func (t *Tree) Set(key []byte, value []byte) (updated bool)
- func (t *Tree) SetBlockHeight(height int64)
- func (t *Tree) Size() int32
- type TreeARC
- type TreeConfig
- type TreeMap
Constants ¶
const (
DefaultPruneHeight = 10000
)
Variables ¶
var ( // ErrNodeNotExist node is not exist ErrNodeNotExist = errors.New("ErrNodeNotExist") )
Functions ¶
func DelLeafCountKV ¶
func DelLeafCountKV(db dbm.DB, blockHeight int64, treeCfg *TreeConfig) error
DelLeafCountKV 回退时候用于删除叶子节点的索引节点
func GetKVPairProof ¶
GetKVPairProof 获取指定k:v pair的proof证明
func InnerNodeProofHash ¶
InnerNodeProofHash 计算inner节点的hash
func IterateRangeByStateHash ¶
func IterateRangeByStateHash(db dbm.DB, statehash, start, end []byte, ascending bool, treeCfg *TreeConfig, fn func([]byte, []byte) bool)
IterateRangeByStateHash 在start和end之间的键进行迭代回调[start, end)
func LoadTree2MemDb ¶
LoadTree2MemDb 从数据库中载入mem tree
func PrintLeafNodeParent ¶
PrintLeafNodeParent 查询叶子节点的父节点
func PrintTreeLeaf ¶
func PrintTreeLeaf(db dbm.DB, roothash []byte, treeCfg *TreeConfig)
PrintTreeLeaf 通过roothash打印所有叶子节点
func PruningTree ¶
func PruningTree(db dbm.DB, curHeight int64, treeCfg *TreeConfig)
PruningTree 裁剪树
func PruningTreePrintDB ¶
PruningTreePrintDB pruning tree print db
Types ¶
type MemTreeOpera ¶
type MemTreeOpera interface { Add(key, value interface{}) Get(key interface{}) (value interface{}, ok bool) Delete(key interface{}) Contains(key interface{}) bool Len() int }
MemTreeOpera memtree操作接口
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node merkle avl Node
type Proof ¶
Proof merkle avl tree proof证明结构体
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree merkle avl tree
func NewTree ¶
func NewTree(db dbm.DB, sync bool, treeCfg *TreeConfig) *Tree
NewTree 新建一个merkle avl 树
func (*Tree) ConstructProof ¶
ConstructProof Returns nil, nil if key is not in tree.
func (*Tree) GetByIndex ¶
GetByIndex 通过index获取leaf节点信息
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) RemoveLeafCountKey ¶
RemoveLeafCountKey 删除叶子节点的索引节点(防止裁剪时候回退产生的误删除)
func (*Tree) SetBlockHeight ¶
SetBlockHeight 设置block高度到tree
type TreeARC ¶
type TreeARC struct {
// contains filtered or unexported fields
}
TreeARC lru的mem tree