iotex-core: github.com/iotexproject/iotex-core/action/protocol Index | Files | Directories

package protocol

import "github.com/iotexproject/iotex-core/action/protocol"

Index

Package Files

context.go generic_validator.go protocol.go registry.go

Variables

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

func WithRunActionsCtx Uses

func WithRunActionsCtx(ctx context.Context, ra RunActionsCtx) context.Context

WithRunActionsCtx add RunActionsCtx into context.

func WithValidateActionsCtx Uses

func WithValidateActionsCtx(ctx context.Context, va ValidateActionsCtx) context.Context

WithValidateActionsCtx add ValidateActionsCtx into context.

type ActionEnvelopeValidator Uses

type ActionEnvelopeValidator interface {
    Validate(context.Context, action.SealedEnvelope) error
}

ActionEnvelopeValidator is the interface of validating an action

type ActionHandler Uses

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 Uses

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

ActionValidator is the interface of validating an action

type ChainManager Uses

type ChainManager interface {
    // ChainID 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)
    // ExecuteContractRead runs a read-only smart contract operation
    ExecuteContractRead(caller address.Address, ex *action.Execution) ([]byte, *action.Receipt, error)
}

ChainManager defines the blockchain interface

type GenericValidator Uses

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

GenericValidator is the validator for generic action verification

func NewGenericValidator Uses

func NewGenericValidator(cm ChainManager) *GenericValidator

NewGenericValidator constructs a new genericValidator

func (*GenericValidator) Validate Uses

func (v *GenericValidator) Validate(ctx context.Context, act action.SealedEnvelope) error

Validate validates a generic action

type MockChainManager Uses

type MockChainManager struct {
}

MockChainManager mocks ChainManager interface

func (*MockChainManager) CandidatesByHeight Uses

func (m *MockChainManager) CandidatesByHeight(height uint64) ([]*state.Candidate, error)

CandidatesByHeight returns the candidate list by a given height

func (*MockChainManager) ChainID Uses

func (m *MockChainManager) ChainID() uint32

ChainID return chain ID

func (*MockChainManager) ExecuteContractRead Uses

func (m *MockChainManager) ExecuteContractRead(caller address.Address, ex *action.Execution) ([]byte, *action.Receipt, error)

ExecuteContractRead runs a read-only smart contract operation

func (*MockChainManager) GetHashByHeight Uses

func (m *MockChainManager) GetHashByHeight(height uint64) (hash.Hash256, error)

GetHashByHeight returns Block's hash by height

func (*MockChainManager) Nonce Uses

func (m *MockChainManager) Nonce(addr string) (uint64, error)

Nonce mocks base method

func (*MockChainManager) ProductivityByEpoch Uses

func (m *MockChainManager) ProductivityByEpoch(epochNum uint64) (uint64, map[string]uint64, error)

ProductivityByEpoch returns the number of produced blocks per delegate in an epoch

func (*MockChainManager) StateByAddr Uses

func (m *MockChainManager) StateByAddr(address string) (*state.Account, error)

StateByAddr returns account of a given address

type Protocol Uses

type Protocol interface {
    ActionValidator
    ActionHandler
    ReadState(context.Context, StateManager, []byte, ...[]byte) ([]byte, error)
}

Protocol defines the protocol interfaces atop IoTeX blockchain

type Registry Uses

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

Registry is the hub of all protocols deployed on the chain

func (*Registry) All Uses

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

All returns all protocols

func (*Registry) Find Uses

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

Find finds a protocol by ID

func (*Registry) ForceRegister Uses

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 Uses

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

Register registers the protocol with a unique ID

type RunActionsCtx Uses

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
    // 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 Uses

func GetRunActionsCtx(ctx context.Context) (RunActionsCtx, bool)

GetRunActionsCtx gets runActions context

func MustGetRunActionsCtx Uses

func MustGetRunActionsCtx(ctx context.Context) RunActionsCtx

MustGetRunActionsCtx must get runActions context. If context doesn't exist, this function panic.

type StateManager Uses

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 Uses

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 Uses

func GetValidateActionsCtx(ctx context.Context) (ValidateActionsCtx, bool)

GetValidateActionsCtx gets validateActions context

func MustGetValidateActionsCtx Uses

func MustGetValidateActionsCtx(ctx context.Context) ValidateActionsCtx

MustGetValidateActionsCtx gets validateActions context. If context doesn't exist, this function panic.

Directories

PathSynopsis
account
account/accountpb
account/util
execution
execution/evm
poll
rewarding
rewarding/rewardingpb
rolldpos
vote/candidatesutil

Package protocol imports 12 packages (graph) and is imported by 17 packages. Updated 2019-10-09. Refresh now. Tools for package owners.