itrie

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: GPL-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

This section is empty.

Types

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 KVStorage

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

func (*KVStorage) Batch

func (kv *KVStorage) Batch() ethdb.Batch

func (*KVStorage) Close

func (kv *KVStorage) Close() error

func (*KVStorage) Get

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

func (*KVStorage) GetCode

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

func (*KVStorage) Set

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

func (*KVStorage) SetCode

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

type Metrics

type Metrics struct {
	CodeLruCacheHit   metrics.Counter
	CodeLruCacheMiss  metrics.Counter
	CodeLruCacheRead  metrics.Counter
	CodeLruCacheWrite metrics.Counter

	AccountStateLruCacheHit metrics.Counter
	TrieStateLruCacheHit    metrics.Counter

	StateLruCacheMiss metrics.Counter
}

Metrics represents the itrie metrics

func GetPrometheusMetrics

func GetPrometheusMetrics(namespace string, labelsWithValues ...string) *Metrics

GetPrometheusMetrics return the blockchain metrics instance

func NewDummyMetrics

func NewDummyMetrics(metrics *Metrics) *Metrics

NewDummyMetrics will return the no nil blockchain metrics TODO: use generic replace this in golang 1.18

func NilMetrics

func NilMetrics() *Metrics

NilMetrics will return the non operational blockchain metrics

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 {
	Set(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 State

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

func NewState

func NewState(storage Storage, metrics *Metrics) *State

func (*State) AddAccountState

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

func (*State) AddTrieState

func (s *State) AddTrieState(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) error

type Storage

type Storage interface {
	Set(k, v []byte) error
	Get(k []byte) ([]byte, bool, error)

	SetCode(hash types.Hash, code []byte) error
	GetCode(hash types.Hash) ([]byte, bool)
	Close() error

	Batch() ethdb.Batch
}

func NewKVStorage

func NewKVStorage(db ethdb.Database) Storage

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 (*Trie) Commit

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

func (*Trie) Get

func (t *Trie) Get(k []byte) ([]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) TryUpdate

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

func (*Trie) Txn

func (t *Trie) Txn() *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