iavl

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: LGPL-3.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IAVLNode

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

func MakeIAVLNode

func MakeIAVLNode(buf []byte, t *IAVLTree) (node *IAVLNode, 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 NewIAVLNode

func NewIAVLNode(key []byte, value []byte) *IAVLNode

type IAVLProof

type IAVLProof struct {
	LeafHash   []byte
	InnerNodes []IAVLProofInnerNode
	RootHash   []byte
}

func ReadProof

func ReadProof(data []byte) (*IAVLProof, error)

ReadProof will deserialize a IAVLProof from bytes

func (*IAVLProof) Root

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

Please leave this here! I use it in light-client to fulfill an interface

func (*IAVLProof) Verify

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

type IAVLProofInnerNode

type IAVLProofInnerNode struct {
	Height int8
	Size   int
	Left   []byte
	Right  []byte
}

func (IAVLProofInnerNode) Hash

func (branch IAVLProofInnerNode) Hash(childHash []byte) []byte

type IAVLProofLeafNode

type IAVLProofLeafNode struct {
	KeyBytes   []byte
	ValueBytes []byte
}

func (IAVLProofLeafNode) Hash

func (leaf IAVLProofLeafNode) Hash() []byte

type IAVLTree

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

Immutable AVL Tree (wraps the Node root) This tree is not goroutine safe.

func NewIAVLTree

func NewIAVLTree(cacheSize int, db dbm.DB) *IAVLTree

NewIAVLTree creates both im-memory and persistent instances

func (*IAVLTree) BatchSet

func (t *IAVLTree) BatchSet(key []byte, value []byte)

BatchSet adds a Set to the current batch, will get handled atomically

func (*IAVLTree) ConstructProof

func (t *IAVLTree) ConstructProof(key []byte) (value []byte, proof *IAVLProof)

Returns nil, nil if key is not in tree.

func (*IAVLTree) Copy

func (t *IAVLTree) Copy() merkle.Tree

The returned tree and the original tree are goroutine independent. That is, they can each run in their own goroutine. However, upon Save(), any other trees that share a db will become outdated, as some nodes will become orphaned. Note that Save() clears leftNode and rightNode. Otherwise, two copies would not be goroutine independent.

func (*IAVLTree) Get

func (t *IAVLTree) Get(key []byte) (index int, value []byte, exists bool)

func (*IAVLTree) GetByIndex

func (t *IAVLTree) GetByIndex(index int) (key []byte, value []byte)

func (*IAVLTree) Has

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

func (*IAVLTree) Hash

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

func (*IAVLTree) HashWithCount

func (t *IAVLTree) HashWithCount() ([]byte, int)

func (*IAVLTree) Height

func (t *IAVLTree) Height() int8

func (*IAVLTree) Iterate

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

func (*IAVLTree) IterateRange

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

IterateRange makes a callback for all nodes with key between start and end inclusive If either are nil, then it is open on that side (nil, nil is the same as Iterate)

func (*IAVLTree) Load

func (t *IAVLTree) Load(hash []byte)

Sets the root node by reading from db. If the hash is empty, then sets root to nil.

func (*IAVLTree) Proof

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

func (*IAVLTree) Remove

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

func (*IAVLTree) Save

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

func (*IAVLTree) Set

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

func (*IAVLTree) Size

func (t *IAVLTree) Size() int

Directories

Path Synopsis
Package iavl is a generated protocol buffer package.
Package iavl is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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