state

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package state implements block chain state trie

Index

Constants

View Source
const TrieKeyValidators = "Validators"

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account interface {
	// account address
	Address() *common.Address

	// account transaction nonce start from 0
	Nonce() uint64
	SetNonce(uint64)
	AddNonce(uint64)

	// account balance in minimum unit
	Balance() *big.Int
	SetBalance(*big.Int)
	AddBalance(*big.Int)
	SubBalance(*big.Int)

	// binary representation for account used as trie value
	ToBytes() ([]byte, error)
}

interface for single account, NO CONCURRENCY 1. cache existing account data in memory 2. cache created / updated account, also providing such operations 3. TODO: handle account storage trie

type AccountTrie

type AccountTrie interface {

	// Get account from trie, create if requested
	GetAccount(address common.Address, createIfMissing bool) Account
	// contains filtered or unexported methods
}

interface for account trie, NO CONCURRENCY 1. cache existing account trie in memory 2. cache created / updated trie, also providing such operations

func NewAccountTrie

func NewAccountTrie(root common.Hash, db Database) (AccountTrie, error)

Create account trie with root hash and backing database

type ConsensusTrie

type ConsensusTrie interface {

	// Get validator address list
	GetValidatorAddr() []common.Address

	// Get / Set validator address str list
	GetValidators() []string
	SetValidators([]string)
	// contains filtered or unexported methods
}

func NewConsensusTrie

func NewConsensusTrie(root common.Hash, db Database) (ConsensusTrie, error)

type Database

type Database interface {
	// open trie with root hash
	OpenTrie(root common.Hash) (Trie, error)

	// copy whatever inner implementation was used
	CopyTrie(trie Trie) Trie

	// retrieves the backing trie DB
	TrieDB() *trie.Database
}

wraps access to state trie, with key length common.AddressLength(20 bytes) wraps access to account storage trie, with key length of hash output(32 bytes) concurrency is allowed for backing multi account trie in different goroutines

func NewDatabase

func NewDatabase(storage persistent.Storage) Database

func NewDatabaseWithCache

func NewDatabaseWithCache(storage persistent.Storage, cache int) Database

type Trie

type Trie interface {
	TryGet(key []byte) ([]byte, error)
	TryUpdate(key, value []byte) error
	TryDelete(key []byte) error
	Commit(onleaf trie.LeafCallback) (common.Hash, error)
	Hash() common.Hash
	NodeIterator(startKey []byte) trie.NodeIterator
}

interface wrapper for trie.Trie

Jump to

Keyboard shortcuts

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