state

package
v0.0.0-...-71debdd Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MIPMapLevels = []uint64{1000000, 500000, 100000, 50000, 1000}
)

Functions

This section is empty.

Types

type DatabaseDeleter

type DatabaseDeleter interface {
	Delete(key []byte) error
}

DatabaseDeleter wraps the Delete method of a backing data store.

type DatabasePutter

type DatabasePutter interface {
	Put(key []byte, value []byte) error
}

DatabasePutter wraps the Put method of a backing data store.

type DatabaseReader

type DatabaseReader interface {
	Get(key []byte) (value []byte, err error)
}

DatabaseReader wraps the Get method of a backing data store.

type State

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

func NewState

func NewState(logger *logrus.Logger, dbFile string, dbCache int) (*State, error)

func (*State) ApplyTransaction

func (s *State) ApplyTransaction(txBytes []byte, txIndex int, blockHash common.Hash) error

ApplyTransaction decodes a transaction and applies it to the WAS. It is meant to be called by the consensus system to apply transactions sequentially.

func (*State) Call

func (s *State) Call(callMsg ethTypes.Message) ([]byte, error)

Call executes a readonly transaction on the statedb. It is called by the service handlers

func (*State) CheckTx

func (s *State) CheckTx(tx *ethTypes.Transaction) error

CheckTx attempt to apply a transaction to the TxPool's statedb. It is called by the Service handlers to check if a transaction is valid before submitting it to the consensus system. This also updates the sender's Nonce in the TxPool's statedb.

func (*State) Commit

func (s *State) Commit() (common.Hash, error)

Commit persists all pending state changes (in the WAS) to the DB, and resets the WAS and TxPool

func (*State) CreateAccounts

func (s *State) CreateAccounts(accounts bcommon.AccountMap) error

CreateAccounts creates new accounts in the state via the WAS.

func (*State) Exist

func (s *State) Exist(addr common.Address) bool

Exist reports whether the given account address exists in the state.

func (*State) GetBalance

func (s *State) GetBalance(addr common.Address) *big.Int

GetBalance returns an account's balance from the main ethState

func (*State) GetNonce

func (s *State) GetNonce(addr common.Address) uint64

GetNonce returns an account's nonce from the main ethState

func (*State) GetPoolNonce

func (s *State) GetPoolNonce(addr common.Address) uint64

GetPoolNonce returns an account's nonce from the txpool's ethState

func (*State) GetReceipt

func (s *State) GetReceipt(txHash common.Hash) (*ethTypes.Receipt, error)

GetReceipt fetches transaction receipts by transaction hash directly from the DB

func (*State) GetTransaction

func (s *State) GetTransaction(hash common.Hash) (*ethTypes.Transaction, error)

GetTransaction fetches transactions by hash directly from the DB.

func (*State) InitState

func (s *State) InitState() error

InitState initializes the statedb object. It checks if there was already a root hash in the underlying database, in which case it initializes the statedb from that root.

type TxPool

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

func NewTxPool

func NewTxPool(ethState *ethState.StateDB,
	signer ethTypes.Signer,
	chainConfig params.ChainConfig,
	vmConfig vm.Config,
	gasLimit uint64,
	logger *logrus.Logger) *TxPool

func (*TxPool) CheckTx

func (p *TxPool) CheckTx(tx *ethTypes.Transaction) error

func (*TxPool) GetNonce

func (p *TxPool) GetNonce(addr common.Address) uint64

func (*TxPool) Reset

func (p *TxPool) Reset(root common.Hash) error

type WriteAheadState

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

WriteAheadState is a wrapper around a DB and StateDB object that applies transactions to the StateDB and only commits them to the DB upon Commit. It also handles persisting transactions, logs, and receipts to the DB. NOT THREAD SAFE

func NewWriteAheadState

func NewWriteAheadState(db ethdb.Database,
	root common.Hash,
	signer ethTypes.Signer,
	chainConfig params.ChainConfig,
	vmConfig vm.Config,
	gasLimit uint64,
	logger *logrus.Logger) (*WriteAheadState, error)

func (*WriteAheadState) ApplyTransaction

func (was *WriteAheadState) ApplyTransaction(tx ethTypes.Transaction, txIndex int, blockHash common.Hash) error

func (*WriteAheadState) Commit

func (was *WriteAheadState) Commit() (common.Hash, error)

func (*WriteAheadState) Reset

func (was *WriteAheadState) Reset(root common.Hash) error

Jump to

Keyboard shortcuts

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