mapstore

package
v0.0.0-...-b49bb9e Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotSetPlaceholder = errors.New("mapstore.Interface: ms.Set: cannot set the value of the placeholder ([]byte{0,0,0...})")

ErrCannotSetPlaceholder is the error returned when Interface.Set is called with the placeholder key.

View Source
var ErrDeleteNotSupported = errors.New("mapstore.Interface: ms.Delete not implemented")

ErrDeleteNotSupported is the error returned when Interface.Delete is not implemented.

View Source
var ErrSkipBranch = errors.New("<ErrSkipBranch>")

ErrSkipBranch is returned by NodeHandler to indicate that children of the current node do not need to be traversed. This error will be ignored if returned by LeafHandler.

Functions

This section is empty.

Types

type Base

type Base interface {
	Get(key []byte) ([]byte, error)
	Set(key, value []byte) error
	Delete(key []byte) error
	Size() int

	ProcessKeys(keys []KeyInfo) error
}

Base is a simplified MapStore. It implements lazyledger/smt.MapStore and can be converted into a dt-compatible MapStore with Wrap(). Base.Delete does not need to be implemented (it may return ErrDeleteNotImplemented).

type Interface

type Interface interface {
	Get(key []byte) ([]byte, error)
	Set(key, value []byte) error
	Delete(key []byte) error
	Size() int

	HashSize() int
	Placeholder() []byte
	TraverseNodes(root []byte, nodeFn NodeHandler, leafFn LeafHandler) error
	SaveNodesForRoot(root []byte) error
}

Interface is the interface implemented by all dt-compatible MapStores. It is an extension of Base.

func NewMem

func NewMem(hashSize int) Interface

NewMem creates a new DDMapStore with the given hash size

func Wrap

func Wrap(hashSize int, base Base) Interface

Wrap creates a new mapstore.Interface from the specified lazyledger/smt.MapStore.

type KeyInfo

type KeyInfo struct {
	Key        []byte
	ShouldSave bool
}

KeyInfo stores information about a key

type LeafHandler

type LeafHandler func(leafPath, hash, valueHash []byte) error

LeafHandler is used in TraverseNodes.

type NodeHandler

type NodeHandler func(hash, left, right []byte) error

NodeHandler is used in TraverseNodes.

Jump to

Keyboard shortcuts

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