executor

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

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

Go to latest
Published: Aug 23, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EVM vmType = iota
	EWASM
	JSVM
)

Variables

This section is empty.

Functions

func ApplyTx

func ApplyTx(virtualMachine vm.VM, tx *types.Transaction) ([]byte, uint64, bool, error)

Make state transition by applying a new event

func NewVM

func NewVM(config *common.Config, tx *types.Transaction, header *types.Header, bc *chain.Blockchain, author *common.Address, statedb *state.StateDB) vm.VM

Types

type BlockValidator

type BlockValidator interface {
	ValidateHeader(header *types.Header) error
	ValidateHeaders(headers []*types.Header) (chan struct{}, chan error)
	ValidateBody(b *types.Block) error
	ValidateState(b *types.Block, state *state.StateDB, receipts types.Receipts) error
}

type BlockValidatorImpl

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

func NewBlockValidator

func NewBlockValidator(config *common.Config, chain chain.Blockchain) *BlockValidatorImpl

func (*BlockValidatorImpl) ValidateBody

func (v *BlockValidatorImpl) ValidateBody(block *types.Block) error

Validate block body 1. Check block already exist in db or not 1. Check transactions match tx root in header or not

func (*BlockValidatorImpl) ValidateHeader

func (v *BlockValidatorImpl) ValidateHeader(header *types.Header) error

ValidateHeader validate headers, called by outer obj 1. check header already exist or not 2. check parent exist or not 3. check detail header info

func (*BlockValidatorImpl) ValidateHeaders

func (v *BlockValidatorImpl) ValidateHeaders(headers []*types.Header) (chan struct{}, chan error)

ValidateHeaders validate headers in batch, used by sync-chain processing. It returns two channels, one is to abort the validate process, and the other is to store errors。

func (*BlockValidatorImpl) ValidateState

func (v *BlockValidatorImpl) ValidateState(block *types.Block, state *state.StateDB, receipts types.Receipts) error

Validate block txs 1. Validate receipts root hash 2. Validate Bloom filter 3. Validate state root

type Config

type Config struct {
	MaxGasLimit uint64
}

func NewConfig

func NewConfig(config *common.Config) *Config

type Executor

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

func New

func New(config *common.Config, database db.Database, chain chain.Blockchain, engine consensus.Engine) *Executor

func (*Executor) Init

func (ex *Executor) Init() error

func (*Executor) Process

func (ex *Executor) Process(block *types.Block) (types.Receipts, error)

Process apply transaction in state

func (*Executor) Start

func (ex *Executor) Start() error

func (*Executor) Stop

func (ex *Executor) Stop() error

type GasPool

type GasPool uint64

GasPool tracks the amount of gas available during execution of the transactions in a block. The zero value is a pool with zero gas available.

func (*GasPool) AddGas

func (gp *GasPool) AddGas(amount uint64) *GasPool

AddGas makes gas available for execution.

func (*GasPool) Gas

func (gp *GasPool) Gas() uint64

Gas returns the amount of gas remaining in the pool.

func (*GasPool) String

func (gp *GasPool) String() string

func (*GasPool) SubGas

func (gp *GasPool) SubGas(amount uint64) error

SubGas deducts the given amount from the pool if enough gas is available and returns an error otherwise.

type Processor

type Processor interface {
	Process(block *types.Block) (types.Receipts, error)
}

Processor represents the interface of block processor

type StateTransition

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

func NewStateTransition

func NewStateTransition(virtualMachine vm.VM, tx *types.Transaction) *StateTransition

func (*StateTransition) Process

func (st *StateTransition) Process() ([]byte, uint64, bool, error)

Make state transition according to transaction event

type TxValidator

type TxValidator interface {
	ValidateTxs(types.Transactions) (types.Transactions, types.Transactions)
	ValidateTx(*types.Transaction) error
}

type TxValidatorImpl

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

func NewTxValidator

func NewTxValidator(config *common.Config, state *state.StateDB) *TxValidatorImpl

func (*TxValidatorImpl) ValidateTx

func (v *TxValidatorImpl) ValidateTx(tx *types.Transaction) error

Validate transaction 1. check tx size 2. check tx value 3. check address is match 4. check signature is match 5. check nonce 6. check balance is enough or not for tx.Cost()

func (*TxValidatorImpl) ValidateTxs

func (v *TxValidatorImpl) ValidateTxs(txs types.Transactions) (valid types.Transactions, invalid types.Transactions)

Jump to

Keyboard shortcuts

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