trie

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: GPL-3.0 Imports: 19 Imported by: 7

Documentation

Overview

Package trie implements Merkle Patricia Tries

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyProcessed = errors.New("already processed")
View Source
var ErrNotRequested = errors.New("not requested")

Functions

func VerifyProof

func VerifyProof(rootHash common.Hash, key []byte, proofDb neatdb.Reader) (value []byte, nodes int, err error)

Types

type Database

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

func NewDatabase

func NewDatabase(diskdb neatdb.KeyValueStore) *Database

func NewDatabaseWithCache

func NewDatabaseWithCache(diskdb neatdb.KeyValueStore, cache int) *Database

func (*Database) Cap

func (db *Database) Cap(limit common.StorageSize) error

func (*Database) Commit

func (db *Database) Commit(node common.Hash, report bool) error

func (*Database) Dereference

func (db *Database) Dereference(root common.Hash)

func (*Database) DiskDB

func (db *Database) DiskDB() neatdb.Reader

func (*Database) InsertBlob

func (db *Database) InsertBlob(hash common.Hash, blob []byte)

func (*Database) Node

func (db *Database) Node(hash common.Hash) ([]byte, error)

func (*Database) Nodes

func (db *Database) Nodes() []common.Hash

func (*Database) Reference

func (db *Database) Reference(side common.Hash, parent common.Hash)

func (*Database) Size

type Iterator

type Iterator struct {
	Key   []byte
	Value []byte
	Err   error
	// contains filtered or unexported fields
}

func NewIterator

func NewIterator(it NodeIterator) *Iterator

func (*Iterator) Next

func (it *Iterator) Next() bool

func (*Iterator) Prove

func (it *Iterator) Prove() [][]byte

type LeafCallback

type LeafCallback func(leaf []byte, parent common.Hash) error

type MissingNodeError

type MissingNodeError struct {
	NodeHash common.Hash
	Path     []byte
}

func (*MissingNodeError) Error

func (err *MissingNodeError) Error() string

type NodeIterator

type NodeIterator interface {
	Next(bool) bool

	Error() error

	Hash() common.Hash

	Parent() common.Hash

	Path() []byte

	Leaf() bool

	LeafKey() []byte

	LeafBlob() []byte

	LeafProof() [][]byte
}

func NewDifferenceIterator

func NewDifferenceIterator(a, b NodeIterator) (NodeIterator, *int)

func NewUnionIterator

func NewUnionIterator(iters []NodeIterator) (NodeIterator, *int)

type SecureTrie

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

func NewSecure

func NewSecure(root common.Hash, db *Database) (*SecureTrie, error)

func (*SecureTrie) Commit

func (t *SecureTrie) Commit(onleaf LeafCallback) (root common.Hash, err error)

func (*SecureTrie) Copy

func (t *SecureTrie) Copy() *SecureTrie

func (*SecureTrie) Delete

func (t *SecureTrie) Delete(key []byte)

func (*SecureTrie) Get

func (t *SecureTrie) Get(key []byte) []byte

func (*SecureTrie) GetKey

func (t *SecureTrie) GetKey(shaKey []byte) []byte

func (*SecureTrie) Hash

func (t *SecureTrie) Hash() common.Hash

func (*SecureTrie) NodeIterator

func (t *SecureTrie) NodeIterator(start []byte) NodeIterator

func (*SecureTrie) Prove

func (t *SecureTrie) Prove(key []byte, fromLevel uint, proofDb neatdb.Writer) error

func (*SecureTrie) TryDelete

func (t *SecureTrie) TryDelete(key []byte) error

func (*SecureTrie) TryGet

func (t *SecureTrie) TryGet(key []byte) ([]byte, error)

func (*SecureTrie) TryUpdate

func (t *SecureTrie) TryUpdate(key, value []byte) error

func (*SecureTrie) Update

func (t *SecureTrie) Update(key, value []byte)

type Sync

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

func NewSync

func NewSync(root common.Hash, database neatdb.Reader, callback LeafCallback) *Sync

func (*Sync) AddRawEntry

func (s *Sync) AddRawEntry(hash common.Hash, depth int, parent common.Hash)

func (*Sync) AddSubTrie

func (s *Sync) AddSubTrie(root common.Hash, depth int, parent common.Hash, callback LeafCallback)

func (*Sync) Commit

func (s *Sync) Commit(dbw neatdb.Writer) (int, error)

func (*Sync) Missing

func (s *Sync) Missing(max int) []common.Hash

func (*Sync) Pending

func (s *Sync) Pending() int

func (*Sync) Process

func (s *Sync) Process(results []SyncResult) (bool, int, error)

type SyncResult

type SyncResult struct {
	Hash common.Hash
	Data []byte
}

type Trie

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

func New

func New(root common.Hash, db *Database) (*Trie, error)

func (*Trie) Commit

func (t *Trie) Commit(onleaf LeafCallback) (root common.Hash, err error)

func (*Trie) Delete

func (t *Trie) Delete(key []byte)

func (*Trie) Get

func (t *Trie) Get(key []byte) []byte

func (*Trie) Hash

func (t *Trie) Hash() common.Hash

func (*Trie) NodeIterator

func (t *Trie) NodeIterator(start []byte) NodeIterator

func (*Trie) Prove

func (t *Trie) Prove(key []byte, fromLevel uint, proofDb neatdb.Writer) error

func (*Trie) TryDelete

func (t *Trie) TryDelete(key []byte) error

func (*Trie) TryGet

func (t *Trie) TryGet(key []byte) ([]byte, error)

func (*Trie) TryUpdate

func (t *Trie) TryUpdate(key, value []byte) error

func (*Trie) Update

func (t *Trie) Update(key, value []byte)

Jump to

Keyboard shortcuts

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