types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: Apache-2.0 Imports: 9 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// ClientTypeNil nil type for chain
	ClientTypeNil = ClientType(iota)
	FORCEIO
	EOSForce
	Codex
	EOSIO
	ENU     // no support now
	BOS     // no support now
	TLOS    // no support now
	MEETONE // no support now
)

Variables

View Source
var (
	ErrTypeErrToChain = errors.New("ErrTypeErrToChain")
	ErrNoSupportChain = errors.New("ErrNoSupportChain")
)

Functions

This section is empty.

Types

type Action

type Action struct {
	Account       string
	Name          string
	Authorization []PermissionLevel
	Data          interface{}
	HexData       []byte
}

func (*Action) FromEOSForce

func (a *Action) FromEOSForce(act *eosforce.Action) error

func (*Action) FromEOSIO

func (a *Action) FromEOSIO(act *eosio.Action) error

func (*Action) FromForceio

func (a *Action) FromForceio(act *forceio.Action) error

func (*Action) ToEOSForce

func (a *Action) ToEOSForce() (*eosforce.Action, error)

func (*Action) ToEOSIO

func (a *Action) ToEOSIO() (*eosio.Action, error)

func (*Action) ToForceio

func (a *Action) ToForceio() (*forceio.Action, error)

type Asset

type Asset struct {
	Amount int64
	Symbol
}

type BlockGeneralInfo

type BlockGeneralInfo struct {
	ID               Checksum256          `json:"id"`
	BlockNum         uint32               `json:"block_num"`
	Timestamp        time.Time            `json:"timestamp"`
	Producer         string               `json:"producer"`
	Confirmed        uint16               `json:"confirmed"`
	Previous         Checksum256          `json:"previous"`
	TransactionMRoot Checksum256          `json:"transaction_mroot"`
	ActionMRoot      Checksum256          `json:"action_mroot"`
	ScheduleVersion  uint32               `json:"schedule_version"`
	Transactions     []TransactionReceipt `json:"transactions"`
}

type BlockResp

type BlockResp struct {
	BlockGeneralInfo
	ID             Checksum256 `json:"id"`
	BlockNum       uint32      `json:"block_num"`
	RefBlockPrefix uint32      `json:"ref_block_prefix"`
}

type Checksum256

type Checksum256 []byte

Checksum256 a general type for xxx.Checksum256

func (Checksum256) MarshalJSON

func (t Checksum256) MarshalJSON() ([]byte, error)

MarshalJSON to json

func (Checksum256) String

func (t Checksum256) String() string

func (*Checksum256) UnmarshalJSON

func (t *Checksum256) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON from json

type ClientInterface

type ClientInterface interface {
	Type() ClientType
	Switcher() SwitcherInterface
	Init(cfg *config.ConfigData) error
	PushActions(actions ...*Action) (*PushTransactionFullResp, error)
	GetInfoData() (*InfoResp, error)
	GetBlockDataByID(id string) (*BlockGeneralInfo, error)
	GetBlockDataByNum(num uint32) (*BlockGeneralInfo, error)
	Name(n string) interface{}
	Asset(a *Asset) interface{}
}

ClientInterface client interface for all client

type ClientType

type ClientType uint8

ClientType chain client type

func String2ClientType

func String2ClientType(str string) ClientType

String2ClientType string to clientType

func (ClientType) String

func (c ClientType) String() string

type InfoResp

type InfoResp struct {
	ServerVersion            string      `json:"server_version"`
	ChainID                  Checksum256 `json:"chain_id"`
	HeadBlockNum             uint32      `json:"head_block_num"`
	LastIrreversibleBlockNum uint32      `json:"last_irreversible_block_num"`
	LastIrreversibleBlockID  Checksum256 `json:"last_irreversible_block_id"`
	HeadBlockID              Checksum256 `json:"head_block_id"`
	HeadBlockTime            time.Time   `json:"head_block_time"`
	HeadBlockProducer        string      `json:"head_block_producer"`
	VirtualBlockCPULimit     int64       `json:"virtual_block_cpu_limit"`
	VirtualBlockNetLimit     int64       `json:"virtual_block_net_limit"`
	BlockCPULimit            int64       `json:"block_cpu_limit"`
	BlockNetLimit            int64       `json:"block_net_limit"`
	ServerVersionString      string      `json:"server_version_string"`
}

type P2PHandler

type P2PHandler interface {
	OnBlock(peer string, msg *BlockGeneralInfo) error
	OnGoAway(peer string, reason uint8, nodeID Checksum256) error
}

P2PHandler a general p2p msg handler interface for each chain

type PermissionLevel

type PermissionLevel struct {
	Actor      string `json:"actor"`
	Permission string `json:"permission"`
}

type PushTransactionFullResp

type PushTransactionFullResp struct {
	StatusCode     string
	TransactionID  string `json:"transaction_id"`
	ProcessedDatas []byte `json:"processed"` // WARN: is an `fc::variant` in server..
	BlockID        string `json:"block_id"`
	BlockNum       uint32 `json:"block_num"`
}

PushTransactionFullResp

func (*PushTransactionFullResp) FillProcessedDatas

func (p *PushTransactionFullResp) FillProcessedDatas(data interface{}) error

type SwitcherInterface

type SwitcherInterface interface {
	Type() ClientType
	NameFromCommon(n string) interface{}
	Checksum256FromCommon(c Checksum256) interface{}
	PushTransactionFullRespToCommon(r interface{}) (*PushTransactionFullResp, error)
	BlockRspToCommon(r interface{}) (*BlockResp, error)
	InfoRespToCommon(r interface{}) (*InfoResp, error)
	ActionToCommon(d interface{}) (*Action, error)
	ActionFromCommon(d *Action) (interface{}, error)
	TransactionToCommon(r interface{}) (*TransactionGeneralInfo, error)
	BlockToCommon(r interface{}) (*BlockGeneralInfo, error)

	UnpackTransferAction(raw []byte) (*TransferActionData, error)
}

SwitcherInterface a interface for diff chain type transfer to common

func NewSwitcherInterface

func NewSwitcherInterface(typ ClientType) SwitcherInterface

NewSwitcherInterface create SwitcherInterface by typ

type Symbol

type Symbol struct {
	Precision uint8
	Symbol    string
}

type TransactionGeneralInfo

type TransactionGeneralInfo struct {
	ID                 Checksum256
	Expiration         time.Time `json:"expiration"`
	RefBlockNum        uint16    `json:"ref_block_num"`
	RefBlockPrefix     uint32    `json:"ref_block_prefix"`
	MaxNetUsageWords   uint32    `json:"max_net_usage_words"`
	MaxCPUUsageMS      uint8     `json:"max_cpu_usage_ms"`
	DelaySec           uint32    `json:"delay_sec"`
	ContextFreeActions []*Action `json:"context_free_actions"`
	Actions            []*Action `json:"actions"`
	ContextFreeData    [][]byte  `json:"context_free_data"`
}

TransactionGeneralInfo Transaction data for each chain

type TransactionReceipt

type TransactionReceipt struct {
	Status               TransactionStatus      `json:"status"`
	CPUUsageMicroSeconds uint32                 `json:"cpu_usage_us"`
	NetUsageWords        uint32                 `json:"net_usage_words"`
	Transaction          TransactionGeneralInfo `json:"trx"`
}

type TransactionStatus

type TransactionStatus uint8
const (
	TransactionStatusExecuted TransactionStatus = iota ///< succeed, no error handler executed
	TransactionStatusSoftFail                          ///< objectively failed (not executed), error handler executed
	TransactionStatusHardFail                          ///< objectively failed and error handler objectively failed thus no state change
	TransactionStatusDelayed                           ///< transaction delayed
	TransactionStatusExpired                           ///< transaction expired
	TransactionStatusUnknown  = TransactionStatus(255)
)

type TransferActionData

type TransferActionData struct {
	From     string `json:"from"`
	To       string `json:"to"`
	Quantity Asset  `json:"quantity"`
	Memo     string `json:"memo"`
}

TransferActionData data for transfer action

Jump to

Keyboard shortcuts

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