trie

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RADIX equals 2^Nibble, where Nibble is the number of bits to be parsed each time
	RADIX = 256
	// BRANCH means the node is a branch
	BRANCH = 1
	// EXTLEAF means the node is an ext or leaf
	EXTLEAF = 0
)

Variables

View Source
var (
	// ErrInvalidPatricia indicates invalid operation
	ErrInvalidPatricia = errors.New("invalid patricia operation")

	// ErrPathDiverge indicates the path diverges
	ErrPathDiverge = errors.New("path diverges")
)
View Source
var (
	// AccountKVNameSpace is the bucket name for account trie
	AccountKVNameSpace = "Account"

	// CodeKVNameSpace is the bucket name for code
	CodeKVNameSpace = "Code"

	// ContractKVNameSpace is the bucket name for contract data storage
	ContractKVNameSpace = "Contract"

	// CandidateKVNameSpace is the bucket name for candidate data storage
	CandidateKVNameSpace = "Candidate"

	// ErrInvalidTrie indicates something wrong causing invalid operation
	ErrInvalidTrie = errors.New("invalid trie operation")

	// ErrNotExist indicates entry does not exist
	ErrNotExist = errors.New("not exist in trie")

	// EmptyRoot is the root hash of an empty trie
	EmptyRoot = hash.Hash32B{0xe, 0x57, 0x51, 0xc0, 0x26, 0xe5, 0x43, 0xb2, 0xe8, 0xab, 0x2e, 0xb0, 0x60, 0x99,
		0xda, 0xa1, 0xd1, 0xe5, 0xdf, 0x47, 0x77, 0x8f, 0x77, 0x87, 0xfa, 0xab, 0x45, 0xcd, 0xf1, 0x2f, 0xe3, 0xa8}
)

Functions

This section is empty.

Types

type Trie

type Trie interface {
	lifecycle.StartStopper
	TrieDB() db.KVStore          // return the underlying DB instance
	Upsert([]byte, []byte) error // insert a new entry
	Get([]byte) ([]byte, error)  // retrieve an existing entry
	Delete([]byte) error         // delete an entry
	Commit() error               // commit the state changes in a batch
	RootHash() hash.Hash32B      // returns trie's root hash
	SetRoot(hash.Hash32B) error  // set a new root to trie
}

Trie is the interface of Merkle Patricia Trie

func NewTrie

func NewTrie(kvStore db.KVStore, name string, root hash.Hash32B) (Trie, error)

NewTrie creates a trie with DB filename

func NewTrieSharedBatch added in v0.4.0

func NewTrieSharedBatch(kvStore db.KVStore, batch db.CachedBatch, name string, root hash.Hash32B) (Trie, error)

NewTrieSharedBatch creates a trie with a shared batch

Jump to

Keyboard shortcuts

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