itrie

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStateTransactionIsCancel = errors.New("transaction is cancel")
)

Functions

This section is empty.

Types

type Batch

type Batch interface {
	StorageWriter

	Commit() error
}

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 Metrics added in v1.2.0

type Metrics interface {
	// contains filtered or unexported methods
}

func GetPrometheusMetrics added in v1.2.0

func GetPrometheusMetrics(namespace string, trackingIOTimer bool, labelsWithValues ...string) Metrics

GetPrometheusMetrics return the blockchain metrics instance

func NilMetrics added in v1.2.0

func NilMetrics() Metrics

NilMetrics will return the non operational blockchain metrics

type MetricsTimeendRecord added in v1.2.2

type MetricsTimeendRecord func()

type Node

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

Node represents a node reference

func GetNode

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

GetNode retrieves a node from storage

type NodePool added in v1.2.2

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

func NewNodePool added in v1.2.2

func NewNodePool() *NodePool

func (*NodePool) GetFullNode added in v1.2.2

func (np *NodePool) GetFullNode() *FullNode

func (*NodePool) GetShortNode added in v1.2.2

func (np *NodePool) GetShortNode() *ShortNode

func (*NodePool) GetValueNode added in v1.2.2

func (np *NodePool) GetValueNode() *ValueNode

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 added in v1.2.4

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

func (*Snapshot) Commit added in v1.2.4

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

func (*Snapshot) GetAccount added in v1.2.4

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

func (*Snapshot) GetCode added in v1.2.4

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

func (*Snapshot) GetStorage added in v1.2.4

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

type StateDB added in v1.2.2

type StateDB interface {
	StateDBReader

	Transaction(execute func(st StateDBTransaction) error) error

	GetMetrics() Metrics

	Logger() hclog.Logger
}

func NewStateDB added in v1.2.2

func NewStateDB(storage Storage, logger hclog.Logger, metrics Metrics) StateDB

type StateDBReader added in v1.2.2

type StateDBReader interface {
	StorageReader

	GetCode(hash types.Hash) ([]byte, bool)

	NewSnapshot() state.Snapshot
	NewSnapshotAt(types.Hash) (state.Snapshot, error)
}

type StateDBTransaction added in v1.2.2

type StateDBTransaction interface {
	StateDBReader
	StorageWriter

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

	Commit() error
	Rollback()
}

type Storage

type Storage interface {
	StorageReader
	StorageWriter

	NewBatch() Batch
	Close() error
}

Storage stores the trie

func NewLevelDBStorage

func NewLevelDBStorage(leveldbBuilder kvdb.LevelDBBuilder) (Storage, error)

func NewMemoryStorage

func NewMemoryStorage() Storage

NewMemoryStorage creates an inmemory trie storage

type StorageReader added in v1.2.2

type StorageReader interface {
	Get(k []byte) ([]byte, bool, error)
}

Storage stores the trie

type StorageWriter added in v1.2.2

type StorageWriter interface {
	Set(k, v []byte) error
}

type Trie

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

func NewTrie

func NewTrie() *Trie

func (*Trie) Get

func (t *Trie) Get(k []byte, reader StateDBReader) ([]byte, error)

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(reader StateDBReader) *Txn

Txn returns a txn using current db instance

Trie will not hold this db instance

type Txn

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

func (*Txn) Commit

func (t *Txn) Commit() *Trie

Commit returns a committed Trie with the root

func (*Txn) Delete

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

func (*Txn) Hash

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

func (*Txn) Insert

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

func (*Txn) Lookup

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

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