Version: v0.5.0 Latest Latest

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

Go to latest
Published: Apr 21, 2019 License: Apache-2.0 Imports: 11 Imported by: 0




This section is empty.


View Source
var (
	// ErrUnimplemented indicates a method is not implemented yet
	ErrUnimplemented = errors.New("method is unimplemented")


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.


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

type ActionValidator interface {
	Validate(context.Context, action.Action) error

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

Validate validates a generic action

type Protocol

type Protocol interface {
	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) All

func (r *Registry) All() []Protocol

All returns all protocols

func (*Registry) Find

func (r *Registry) Find(id string) (Protocol, bool)

Find finds a protocol by ID

func (*Registry) ForceRegister

func (r *Registry) ForceRegister(id string, p Protocol) error

ForceRegister registers the protocol with a unique ID and force replacing the previous protocol if it exists

func (*Registry) Register

func (r *Registry) Register(id string, p Protocol) error

Register registers the protocol with a unique ID

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL