state

package
v0.0.0-...-305c654 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: MIT Imports: 18 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, genesisFile string) (*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) CreateGenesisAccounts

func (s *State) CreateGenesisAccounts() error

func (*State) Empty

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

Empty reports whether the account is non-existant or empty

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, the write-ahead state, the transaction-pool, and creates genesis accounts.

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