Documentation ¶
Index ¶
- Variables
- func WithRunActionsCtx(ctx context.Context, ra RunActionsCtx) context.Context
- func WithValidateActionsCtx(ctx context.Context, va ValidateActionsCtx) context.Context
- type ActionEnvelopeValidator
- type ActionHandler
- type ActionValidator
- type ChainManager
- type GenericValidator
- type Protocol
- type Registry
- type RunActionsCtx
- type StateManager
- type ValidateActionsCtx
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnimplemented indicates a method is not implemented yet ErrUnimplemented = errors.New("method is unimplemented") )
Functions ¶
func WithRunActionsCtx ¶
func WithRunActionsCtx(ctx context.Context, ra RunActionsCtx) context.Context
WithRunActionsCtx add RunActionsCtx into context.
func WithValidateActionsCtx ¶
func WithValidateActionsCtx(ctx context.Context, va ValidateActionsCtx) context.Context
WithValidateActionsCtx add ValidateActionsCtx into context.
Types ¶
type ActionEnvelopeValidator ¶
type ActionEnvelopeValidator interface {
Validate(context.Context, action.SealedEnvelope) error
}
ActionEnvelopeValidator is the interface of validating an action
type ActionHandler ¶
type ActionHandler interface {
Handle(context.Context, action.Action, StateManager) (*action.Receipt, error)
}
ActionHandler is the interface for the action handlers. For each incoming action, the assembled actions will be called one by one to process it. ActionHandler implementation is supposed to parse the sub-type of the action to decide if it wants to handle this action or not.
type ActionValidator ¶
ActionValidator is the interface of validating an action
type ChainManager ¶
type ChainManager interface { // GetChainID returns the chain ID ChainID() uint32 // GetHashByHeight returns Block's hash by height GetHashByHeight(height uint64) (hash.Hash256, error) // StateByAddr returns account of a given address StateByAddr(address string) (*state.Account, error) // Nonce returns the nonce if the account exists Nonce(addr string) (uint64, error) // CandidatesByHeight returns the candidate list by a given height CandidatesByHeight(height uint64) ([]*state.Candidate, error) // ProductivityByEpoch returns the number of produced blocks per delegate in an epoch ProductivityByEpoch(epochNum uint64) (uint64, map[string]uint64, error) }
ChainManager defines the blockchain interface
type GenericValidator ¶
type GenericValidator struct {
// contains filtered or unexported fields
}
GenericValidator is the validator for generic action verification
func NewGenericValidator ¶
func NewGenericValidator(cm ChainManager, actionGasLimit uint64) *GenericValidator
NewGenericValidator constructs a new genericValidator
func (*GenericValidator) Validate ¶
func (v *GenericValidator) Validate(ctx context.Context, act action.SealedEnvelope) error
Validate validates a generic action
type Protocol ¶
type Protocol interface { ActionValidator ActionHandler ReadState(context.Context, StateManager, []byte, ...[]byte) ([]byte, error) }
Protocol defines the protocol interfaces atop IoTeX blockchain
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the hub of all protocols deployed on the chain
func (*Registry) ForceRegister ¶
ForceRegister registers the protocol with a unique ID and force replacing the previous protocol if it exists
type RunActionsCtx ¶
type RunActionsCtx struct { // height of block containing those actions BlockHeight uint64 // timestamp of block containing those actions BlockTimeStamp time.Time // gas Limit for perform those actions GasLimit uint64 // Producer is the address of whom composes the block containing this action Producer address.Address // Caller is the address of whom issues this action Caller address.Address // ActionHash is the hash of the action with the sealed envelope ActionHash hash.Hash256 // ActionGasLimit is the action gas limit ActionGasLimit uint64 // GasPrice is the action gas price GasPrice *big.Int // IntrinsicGas is the action intrinsic gas IntrinsicGas uint64 // Nonce is the nonce of the action Nonce uint64 // Registry is the pointer protocol registry Registry *Registry }
RunActionsCtx provides the runactions with auxiliary information.
func GetRunActionsCtx ¶
func GetRunActionsCtx(ctx context.Context) (RunActionsCtx, bool)
GetRunActionsCtx gets runActions context
func MustGetRunActionsCtx ¶
func MustGetRunActionsCtx(ctx context.Context) RunActionsCtx
MustGetRunActionsCtx must get runActions context. If context doesn't exist, this function panic.
type StateManager ¶
type StateManager interface { // Accounts Height() uint64 Snapshot() int Revert(int) error // General state State(hash.Hash160, interface{}) error PutState(hash.Hash160, interface{}) error DelState(pkHash hash.Hash160) error GetDB() db.KVStore GetCachedBatch() db.CachedBatch }
StateManager defines the state DB interface atop IoTeX blockchain
type ValidateActionsCtx ¶
type ValidateActionsCtx struct { // height of block containing those actions BlockHeight uint64 // public key of producer who compose those actions ProducerAddr string // Caller is the address of whom issues the action Caller address.Address }
ValidateActionsCtx provides action validators with auxiliary information.
func GetValidateActionsCtx ¶
func GetValidateActionsCtx(ctx context.Context) (ValidateActionsCtx, bool)
GetValidateActionsCtx gets validateActions context
func MustGetValidateActionsCtx ¶
func MustGetValidateActionsCtx(ctx context.Context) ValidateActionsCtx
MustGetValidateActionsCtx gets validateActions context. If context doesn't exist, this function panic.