executor

package
v0.0.0-...-91a82d4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: LGPL-3.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNonceTooLow is returned if the nonce of a transaction is lower than the
	// one present in the local chain.
	ErrNonceTooLow = errors.New("nonce too low")

	// ErrNonceTooHigh is returned if the nonce of a transaction is higher than the
	// next one expected based on the local chain.
	ErrNonceTooHigh = errors.New("nonce too high")
)

Functions

func CanTransfer

func CanTransfer(db vm.StateDB, addr utils.Address, amount *big.Int) bool

CanTransfer checks wether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.

func ExecStateTransition

func ExecStateTransition(txfrom *utils.Address, evm *vm.EVM, tx *types.Transaction, gp *utils.GasPool) ([]byte, uint64, bool, error)

ExecStateTransition computes the new state by applying the given message against the old state within the environment.

func NewEVMContext

func NewEVMContext(tx *types.Transaction, bheader *types.BlockHeader, ledger *ledger.Ledger, engine consensus.Engine, author, txFrom *utils.Address) vm.Context

NewEVMContext creates a new context for use in the EVM.

func Transfer

func Transfer(db vm.StateDB, sender, recipient utils.Address, amount *big.Int)

Transfer subtracts amount from sender and adds amount to recipient using the given Db

Types

type Executor

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

Executor is a transactions executor

func NewExecutor

func NewExecutor(config *params.ChainConfig, l *ledger.Ledger, chain consensus.IChainReader, engine consensus.Engine) *Executor

NewExecutor initialises a new Executor.

func (*Executor) ExecActions

func (e *Executor) ExecActions(statedb *state.StateDB, actions []*types.Action)

ExecActions execute actions

func (*Executor) ExecBlock

func (e *Executor) ExecBlock(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error)

ExecBlock execute block

func (*Executor) ExecTransaction

func (e *Executor) ExecTransaction(author, txFrom *utils.Address,
	dposContext *types.DposContext,
	gp *utils.GasPool, statedb *state.StateDB, header *types.BlockHeader,
	tx *types.Transaction, usedGas *uint64, cfg vm.Config) ([]byte, *types.Receipt, uint64, error)

ExecTransaction attempts to execute a transaction to the given state database and uses the input parameters for its environment.

func (*Executor) SetTxPool

func (e *Executor) SetTxPool(tp ITxPool)

type ITxPool

type ITxPool interface {
	AddAction(a *types.Action)
}

type StateTransition

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

func NewStateTransition

func NewStateTransition(txFrom *utils.Address, evm *vm.EVM, tx *types.Transaction, gp *utils.GasPool) *StateTransition

NewStateTransition initialises and returns a new state transition object.

func NewStateTransitionForApi

func NewStateTransitionForApi(evm *vm.EVM, from utils.Address, tx *types.Transaction, gp *utils.GasPool) *StateTransition

func (*StateTransition) TransitionDb

func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bool, err error)

TransitionDb will transition the state by applying the current message and returning the result including the the used gas.

Jump to

Keyboard shortcuts

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