itrie

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyTrie

func CopyTrie(nodeHash []byte, storage Storage, newStorage Storage, agg []byte, isStorage bool) error

func HashChecker

func HashChecker(stateRoot []byte, storage Storage) (types.Hash, error)

Types

type Batch

type Batch interface {
	Put(k, v []byte)
	Write()
}

type FullNode

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

FullNode is a node with several children

func (*FullNode) Hash

func (c *FullNode) Hash() ([]byte, bool)

Hash implements the node interface

func (*FullNode) SetHash

func (c *FullNode) SetHash(b []byte) []byte

SetHash implements the node interface

type KVBatch

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

KVBatch is a batch write for leveldb

func (*KVBatch) Put

func (b *KVBatch) Put(k, v []byte)

func (*KVBatch) Write

func (b *KVBatch) Write()

type KVStorage

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

KVStorage is a k/v storage on memory using leveldb

func NewKV

func NewKV(db *leveldb.DB) *KVStorage

func (*KVStorage) Batch

func (kv *KVStorage) Batch() Batch

func (*KVStorage) Close

func (kv *KVStorage) Close() error

func (*KVStorage) Get

func (kv *KVStorage) Get(k []byte) ([]byte, bool)

func (*KVStorage) GetCode

func (kv *KVStorage) GetCode(hash types.Hash) ([]byte, bool)

func (*KVStorage) Put

func (kv *KVStorage) Put(k, v []byte)

func (*KVStorage) SetCode

func (kv *KVStorage) SetCode(hash types.Hash, code []byte)

type Node

type Node interface {
	Hash() ([]byte, bool)
	SetHash(b []byte) []byte
}

Node represents a node reference

func GetNode

func GetNode(root []byte, storage Storage) (Node, bool, error)

GetNode retrieves a node from storage

type Putter

type Putter interface {
	Put(k, v []byte)
}

type ShortNode

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

ShortNode is an extension or short node

func (*ShortNode) Hash

func (c *ShortNode) Hash() ([]byte, bool)

Hash implements the node interface

func (*ShortNode) SetHash

func (c *ShortNode) SetHash(b []byte) []byte

SetHash implements the node interface

type Snapshot

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

func (*Snapshot) Commit

func (s *Snapshot) Commit(objs []*state.Object) (state.Snapshot, []byte)

func (*Snapshot) GetAccount

func (s *Snapshot) GetAccount(addr types.Address) (*state.Account, error)

func (*Snapshot) GetCode

func (s *Snapshot) GetCode(hash types.Hash) ([]byte, bool)

func (*Snapshot) GetStorage

func (s *Snapshot) GetStorage(addr types.Address, root types.Hash, rawkey types.Hash) types.Hash

type State

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

func NewState

func NewState(storage Storage) *State

func (*State) AddState

func (s *State) AddState(root types.Hash, t *Trie)

func (*State) GetCode

func (s *State) GetCode(hash types.Hash) ([]byte, bool)

func (*State) NewSnapshot

func (s *State) NewSnapshot() state.Snapshot

func (*State) NewSnapshotAt

func (s *State) NewSnapshotAt(root types.Hash) (state.Snapshot, error)

func (*State) SetCode

func (s *State) SetCode(hash types.Hash, code []byte)

type Storage

type Storage interface {
	Put(k, v []byte)
	Get(k []byte) ([]byte, bool)
	Batch() Batch
	SetCode(hash types.Hash, code []byte)
	GetCode(hash types.Hash) ([]byte, bool)

	Close() error
}

Storage stores the trie

func NewLevelDBStorage

func NewLevelDBStorage(path string, logger hclog.Logger) (Storage, error)

func NewMemoryStorage

func NewMemoryStorage() Storage

NewMemoryStorage creates an inmemory trie storage

type Trie

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

func NewTrie

func NewTrie() *Trie

func NewTrieWithRoot

func NewTrieWithRoot(root Node) *Trie

func (*Trie) Get

func (t *Trie) Get(k []byte, storage Storage) ([]byte, bool)

func (*Trie) Hash

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

Hash returns the root hash of the trie. It does not write to the database and can be used even if the trie doesn't have one.

func (*Trie) Txn

func (t *Trie) Txn(storage Storage) *Txn

type Txn

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

func (*Txn) Commit

func (t *Txn) Commit() *Trie

func (*Txn) Delete

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

func (*Txn) Hash

func (t *Txn) Hash() ([]byte, error)

func (*Txn) Insert

func (t *Txn) Insert(key, value []byte)

func (*Txn) Lookup

func (t *Txn) Lookup(key []byte) []byte

type ValueNode

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

ValueNode is a leaf on the merkle-trie

func (*ValueNode) Hash

func (v *ValueNode) Hash() ([]byte, bool)

Hash implements the node interface

func (*ValueNode) SetHash

func (v *ValueNode) SetHash(b []byte) []byte

SetHash implements the node interface

Jump to

Keyboard shortcuts

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