iotex-core: Index | Files | Directories

package protocol

import ""


Package Files

context.go dock.go generic_validator.go managers.go protocol.go registry.go


const (
    // SystemNamespace is the namespace to store system information such as candidates/probationList/unproductiveDelegates
    SystemNamespace = "System"


var (
    ErrNoName = errors.New("name does not exist")


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

func WithActionCtx Uses

func WithActionCtx(ctx context.Context, ac ActionCtx) context.Context

WithActionCtx add ActionCtx into context.

func WithBlockCtx Uses

func WithBlockCtx(ctx context.Context, blk BlockCtx) context.Context

WithBlockCtx add BlockCtx into context.

func WithBlockchainCtx Uses

func WithBlockchainCtx(ctx context.Context, bc BlockchainCtx) context.Context

WithBlockchainCtx add BlockchainCtx into context.

func WithRegistry Uses

func WithRegistry(ctx context.Context, reg *Registry) context.Context

WithRegistry adds registry to context

type AccountState Uses

type AccountState func(StateReader, string) (*state.Account, error)

AccountState defines a function to return the account state of a given address

type ActionCtx Uses

type ActionCtx struct {
    // 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

ActionCtx provides action auxiliary information.

func GetActionCtx Uses

func GetActionCtx(ctx context.Context) (ActionCtx, bool)

GetActionCtx gets ActionCtx

func MustGetActionCtx Uses

func MustGetActionCtx(ctx context.Context) ActionCtx

MustGetActionCtx must get ActionCtx . If context doesn't exist, this function panic.

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, StateReader) error

ActionValidator is the interface of validating an action

type BlockCtx Uses

type BlockCtx 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

BlockCtx provides block auxiliary information.

func GetBlockCtx Uses

func GetBlockCtx(ctx context.Context) (BlockCtx, bool)

GetBlockCtx gets BlockCtx

func MustGetBlockCtx Uses

func MustGetBlockCtx(ctx context.Context) BlockCtx

MustGetBlockCtx must get BlockCtx . If context doesn't exist, this function panic.

type BlockchainCtx Uses

type BlockchainCtx struct {
    // Genesis is a copy of current genesis
    Genesis genesis.Genesis
    // Tip is the information of tip block
    Tip TipInfo

BlockchainCtx provides blockchain auxiliary information.

func GetBlockchainCtx Uses

func GetBlockchainCtx(ctx context.Context) (BlockchainCtx, bool)

GetBlockchainCtx gets BlockchainCtx

func MustGetBlockchainCtx Uses

func MustGetBlockchainCtx(ctx context.Context) BlockchainCtx

MustGetBlockchainCtx must get BlockchainCtx. If context doesn't exist, this function panic.

type Committer Uses

type Committer interface {
    Commit(context.Context, StateManager) error

Committer performs commit action of the protocol

type Dock Uses

type Dock interface {
    ProtocolDirty(string) bool
    Load(string, string, interface{}) error
    Unload(string, string, interface{}) error

Dock defines an interface for protocol to read/write their private data in StateReader/Manager data are stored as interface{}, user needs to type-assert on their own upon Unload()

func NewDock Uses

func NewDock() Dock

NewDock returns a new dock

type GenericValidator Uses

type GenericValidator struct {
    // contains filtered or unexported fields

GenericValidator is the validator for generic action verification

func NewGenericValidator Uses

func NewGenericValidator(sr StateReader, accountState AccountState) *GenericValidator

NewGenericValidator constructs a new genericValidator

func (*GenericValidator) Validate Uses

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

Validate validates a generic action

type GenesisStateCreator Uses

type GenesisStateCreator interface {
    CreateGenesisStates(context.Context, StateManager) error

GenesisStateCreator creates some genesis states

type PostSystemActionsCreator Uses

type PostSystemActionsCreator interface {
    CreatePostSystemActions(context.Context, StateReader) ([]action.Envelope, error)

PostSystemActionsCreator creates a list of system actions to be appended to block actions

type PreStatesCreator Uses

type PreStatesCreator interface {
    CreatePreStates(context.Context, StateManager) error

PreStatesCreator creates preliminary states for state manager

type Protocol Uses

type Protocol interface {
    ReadState(context.Context, StateReader, []byte, ...[]byte) ([]byte, uint64, error)
    Register(*Registry) error
    ForceRegister(*Registry) error
    Name() string

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

func GetRegistry(ctx context.Context) (*Registry, bool)

GetRegistry returns the registry from context

func MustGetRegistry Uses

func MustGetRegistry(ctx context.Context) *Registry

MustGetRegistry returns the registry from context

func NewRegistry Uses

func NewRegistry() *Registry

NewRegistry create a new Registry

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

func (*Registry) StartAll Uses

func (r *Registry) StartAll(ctx context.Context, sr StateReader) (View, error)

StartAll starts all protocols which are startable

type Starter Uses

type Starter interface {
    Start(context.Context, StateReader) (interface{}, error)

Starter starts the protocol

type StateConfig Uses

type StateConfig struct {
    Namespace string // namespace used by state's storage
    Key       []byte
    MinKey    []byte
    MaxKey    []byte
    Cond      db.Condition

StateConfig is the config for accessing stateDB

func CreateStateConfig Uses

func CreateStateConfig(opts ...StateOption) (*StateConfig, error)

CreateStateConfig creates a config for accessing stateDB

type StateManager Uses

type StateManager interface {
    // Accounts
    Snapshot() int
    Revert(int) error
    // General state
    PutState(interface{}, ...StateOption) (uint64, error)
    DelState(...StateOption) (uint64, error)
    WriteView(string, interface{}) error

StateManager defines the stateDB interface atop IoTeX blockchain

type StateOption Uses

type StateOption func(*StateConfig) error

StateOption sets parameter for access state

func FilterOption Uses

func FilterOption(cond db.Condition, minKey, maxKey []byte) StateOption

FilterOption sets the filter

func KeyOption Uses

func KeyOption(key []byte) StateOption

KeyOption sets the key for call

func LegacyKeyOption Uses

func LegacyKeyOption(key hash.Hash160) StateOption

LegacyKeyOption sets the key for call with legacy key

func NamespaceOption Uses

func NamespaceOption(ns string) StateOption

NamespaceOption creates an option for given namesapce

type StateReader Uses

type StateReader interface {
    Height() (uint64, error)
    State(interface{}, ...StateOption) (uint64, error)
    States(...StateOption) (uint64, state.Iterator, error)
    ReadView(string) (interface{}, error)

StateReader defines an interface to read stateDB

type TipInfo Uses

type TipInfo struct {
    Height    uint64
    Hash      hash.Hash256
    Timestamp time.Time

TipInfo contains the tip block information

type View Uses

type View map[string]interface{}

View stores the view for all protocols

func (View) Read Uses

func (view View) Read(name string) (interface{}, error)

func (View) Write Uses

func (view View) Write(name string, v interface{}) error



Package protocol imports 13 packages (graph) and is imported by 20 packages. Updated 2020-10-25. Refresh now. Tools for package owners.