stateprocessor

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTransaction

func ApplyTransaction(config *params.ChainConfig, header *block.Header, tx *transaction.Transaction, blkCtx *actioncontext.BlockContext) (*transaction.Receipt, error)

ApplyTransaction attempts to apply a transaction to the given state database and uses the input parameters for its environment. It returns the receipt for the transaction and an error if the transaction failed, indicating the block was invalid.

Types

type IChainForState

type IChainForState interface {
	consensus.ChainReader
}

type Message

type Message interface {
	From() types.Address
	Actions() []transaction.Action
	Nonce() uint64
	CheckNonce() bool
}

Message represents a message sent to a contract.

type StateProcessor

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

StateProcessor is a basic Processor, which takes care of transitioning state from one point to another.

StateProcessor implements Processor.

func NewStateProcessor

func NewStateProcessor(config *params.ChainConfig, cs IChainForState, engine consensus.Engine, db database.IDatabase) *StateProcessor

NewStateProcessor initialises a new StateProcessor.

func (*StateProcessor) Process

Process processes the state changes according to the Bchain rules by running the transaction messages using the statedb and applying any rewards to the processor (coinbase).

Process returns the receipts and logs accumulated during the process. If any of the transactions failed it will return an error.

type StateTransition

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

The State Transitioning Model

A state transition is a change made when a transaction is applied to the current world state The state transitioning model does all all the necessary work to work out a valid new state root.

1) Nonce handling 3) Create a new state object if the recipient is \0*32 4) Value transfer == If contract creation ==

4a) Attempt to run transaction data
4b) If valid, use result as code for the new state object

== end == 5) Run Script section 6) Derive new state root

func NewStateTransition

func NewStateTransition(tx *transaction.Transaction, sender types.Address, blkCtx *actioncontext.BlockContext) *StateTransition

NewStateTransition initialises and returns a new state transition object.

func (*StateTransition) TransitionDb

func (st *StateTransition) TransitionDb() (ret []byte, contracts []types.Address, failed bool, err error)

TransitionDb will transition the state by applying the current message and returning the result. It returns an error if it failed. An error indicates a consensus issue.

Jump to

Keyboard shortcuts

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