state

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxTrieCacheGen = uint16(120)

Functions

func TransToSpecBlock

func TransToSpecBlock(db fdb.Database, cache Database, from common.Hash, to common.Hash) error

TransToSpecBlock change block state (from->to)

Types

type Database

type Database interface {
	GetDB() fdb.Database
	OpenTrie(root common.Hash) (Trie, error)
	TrieDB() *trie.Database
	Lock()
	UnLock()
}

Database cache db exported

func NewDatabase

func NewDatabase(db fdb.Database) Database

NewDatabase creates a backing store for state.

type StateDB

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

StateDB store block operate info

func New

func New(root common.Hash, db Database) (*StateDB, error)

New func generate a statedb object parentHash: block's parent hash, db: cachedb

func TraceNew

func TraceNew(blockHash common.Hash, cache Database) (*StateDB, error)

TraceNew get state of special block hash for trace blockHash: the hash of block

func (*StateDB) AddLog

func (s *StateDB) AddLog(log *types.Log)

AddLog save transaction log

func (*StateDB) AddPreimage

func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte)

AddPreimage hash is preimageHash

func (*StateDB) AddRefund

func (s *StateDB) AddRefund(gas uint64)

save unuse gas

func (*StateDB) Commit

func (s *StateDB) Commit(batch fdb.Batch, blockHash common.Hash, blockNum uint64) (common.Hash, error)

Commit the block state to db. after success please call commitcache batch: batch to db blockHash: the hash of commit block

func (*StateDB) Copy

func (s *StateDB) Copy() *StateDB

func (*StateDB) Database

func (s *StateDB) Database() Database

func (*StateDB) Delete

func (s *StateDB) Delete(account string, key string)

Delete account's data from db

func (*StateDB) Error

func (s *StateDB) Error() error

Error return error info

func (*StateDB) Finalise

func (s *StateDB) Finalise()

func (*StateDB) Get

func (s *StateDB) Get(account string, key string) ([]byte, error)

Get account's data from db

func (*StateDB) GetLogs

func (s *StateDB) GetLogs(hash common.Hash) []*types.Log

GetLogs get a strip of transaction log

func (*StateDB) GetRefund

func (s *StateDB) GetRefund() uint64

func (*StateDB) GetState

func (s *StateDB) GetState(account string, key common.Hash) common.Hash

func (*StateDB) IntermediateRoot

func (s *StateDB) IntermediateRoot() common.Hash

func (*StateDB) Logs

func (s *StateDB) Logs() []*types.Log

Logs get all transaction log

func (*StateDB) Preimages

func (s *StateDB) Preimages() map[common.Hash][]byte

Preimages return preimages

func (*StateDB) Prepare

func (s *StateDB) Prepare(thash, bhash common.Hash, ti int)

execute transaction called

func (*StateDB) Put

func (s *StateDB) Put(account string, key string, value []byte)

Put account's data to db

func (*StateDB) ReceiptRoot

func (s *StateDB) ReceiptRoot() common.Hash

ReceiptRoot compute one tx‘ receipt hash

func (*StateDB) Reset

func (s *StateDB) Reset(root common.Hash) error

Reset clear StateDB

func (*StateDB) RevertToSnapshot

func (s *StateDB) RevertToSnapshot(revid int)

func (*StateDB) RpcGet

func (s *StateDB) RpcGet(account string, key string) ([]byte, error)

RpcGet provide get value of the key to rpc when called please RLock cachedb

func (*StateDB) RpcGetState

func (s *StateDB) RpcGetState(account string, key common.Hash) common.Hash

RpcGetState provide get value of the key to rpc when called please RLock cachedb

func (*StateDB) SetState

func (s *StateDB) SetState(account string, key, value common.Hash)

set contract variable key value

func (*StateDB) Snapshot

func (s *StateDB) Snapshot() int

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
	GetKey([]byte) []byte // TODO(fjl): remove this when SecureTrie is removed
	Prove(key []byte, fromLevel uint, proofDb fdb.Putter) error
}

Directories

Path Synopsis
package mtp implements Merkle Patricia Tries.
package mtp implements Merkle Patricia Tries.

Jump to

Keyboard shortcuts

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