itrie

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 (*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 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 (*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

func (*Txn) Show

func (t *Txn) Show()

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