state

package
v0.0.0-...-77adb20 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 21 Imported by: 12

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)

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

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

func (*State) GetBlock

func (s *State) GetBlock(hash common.Hash) (*poset.Block, error)

func (*State) GetBlockById

func (s *State) GetBlockById(id int64) (*poset.Block, error)

func (*State) GetBlockIndex

func (s *State) GetBlockIndex() int64

func (*State) GetFailedTx

func (s *State) GetFailedTx(txHash common.Hash) (*TxError, error)

func (*State) GetNonce

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

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)

func (*State) GetTransaction

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

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.

func (*State) PrintTransaction

func (s *State) PrintTransaction(tx *ethTypes.Transaction) string

func (*State) ProcessBlock

func (s *State) ProcessBlock(block poset.Block) (common.Hash, error)

type TxError

type TxError struct {
	Tx    ethTypes.Transaction `json:"tx"`
	Error string               `json:"error"`
}

func (*TxError) GetError

func (te *TxError) GetError() string

func (*TxError) GetTx

func (te *TxError) GetTx() *ethTypes.Transaction

func (*TxError) Marshal

func (te *TxError) Marshal() ([]byte, error)

func (*TxError) Unmarshal

func (te *TxError) Unmarshal(data []byte) error

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
}

write ahead state, updated with each AppendTx and reset on Commit

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