protocol

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 9 Imported by: 41

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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

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.Hash32B, 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)
}

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) *GenericValidator

NewGenericValidator constructs a new genericValidator

func (*GenericValidator) Validate

Validate validates a generic action

type Protocol

type Protocol interface {
	ActionValidator
	ActionHandler
}

Protocol defines the protocol interfaces atop IoTeX blockchain

type RunActionsCtx

type RunActionsCtx struct {
	// EpochNumber is the epoch number
	EpochNumber uint64
	// height of block containing those actions
	BlockHeight uint64
	// hash of block containing those actions
	BlockHash hash.Hash32B
	// timestamp of block containing those actions
	BlockTimeStamp int64
	// gas Limit for perform those actions
	GasLimit *uint64
	// whether disable gas charge
	EnableGasCharge bool
	// 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.Hash32B
	// Nonce is the nonce of the action
	Nonce uint64
}

RunActionsCtx provides the runactions with auxiliary information.

func GetRunActionsCtx

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

GetRunActionsCtx gets runActions context

type StateManager

type StateManager interface {
	// Accounts
	Height() uint64
	Snapshot() int
	Revert(int) error
	// General state
	State(hash.PKHash, interface{}) error
	PutState(hash.PKHash, interface{}) error
	DelState(pkHash hash.PKHash) 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

Jump to

Keyboard shortcuts

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