state

package
v0.0.3-unstable Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: GPL-3.0 Imports: 13 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 {
	Get(key string) ([]byte, error)
	Put(key string, value []byte) error
	Delete(key string) error
	PutCache(key string, value []byte) error
	DeleteCache(key string) error
	GetDB() fdb.Database
	GetHash() common.Hash
	SetHash(hash common.Hash)
	Lock()
	UnLock()
	RLock()
	RUnLock()
	Purge()
}

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(parentHash 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)

save transaction log

func (*StateDB) AddPreimage

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

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) CommitCache

func (s *StateDB) CommitCache(blockHash common.Hash)

CommitCache commit the block state to cache call after state commit to db success

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

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

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

get all transaction log

func (*StateDB) Preimages

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

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() error

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

Jump to

Keyboard shortcuts

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