define

package
v0.0.0-...-48972bb Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeType_OK uint32 = 0
	// General response codes, 0 ~ 99
	CodeType_InternalError     uint32 = 1  //内部错误
	CodeType_EncodingError     uint32 = 2  //编解码错误
	CodeType_BadNonce          uint32 = 3  //nonce错误
	CodeType_Unauthorized      uint32 = 4  //未授权
	CodeType_InsufficientFunds uint32 = 5  //资金不足
	CodeType_UnknownRequest    uint32 = 6  //未知请求
	CodeType_InvalidTx         uint32 = 7  //交易不合法
	CodeType_UnknownAccount    uint32 = 8  //未知帐户
	CodeType_AccountExist      uint32 = 9  //帐户已存在
	CodeType_AccountNotFound   uint32 = 10 //帐户不存在
	CodeType_OutOfOrder        uint32 = 11 //action顺序错误
	CodeType_UnknownError      uint32 = 12 //未知错误
	CodeType_SignerFaild       uint32 = 13 //签名错误
)

Variables

This section is empty.

Functions

func Signer

func Signer(tx *Transaction, sig []byte) (ethcmn.Address, error)

Types

type Action

type Action struct {
	ID        uint8          // 最大支持255笔交易
	CreatedAt uint64         // 时间
	Src       ethcmn.Address //
	Dst       ethcmn.Address //
	Amount    *big.Int       //
	Data      string         // 用户数据
	Memo      string         // 备注
	SignHex   [65]byte       // 签名 65 bytes
}

type AppHeader

type AppHeader struct {
	PrevHash  ethcmn.Hash // global, just used to calculate header-hash
	StateRoot ethcmn.Hash // fill after statedb commit
	BlockHash ethcmn.Hash //区块hash
	Height    uint64      // refresh by new block
	TxCount   uint64      // fill when ready to save
	OpCount   uint64      // fill when ready to save
	ClosedAt  time.Time   // refresh by new block
}

func (*AppHeader) Hash

func (h *AppHeader) Hash() []byte

Hash hash

func (*AppHeader) String

func (h *AppHeader) String() string

type BlockAccount

type BlockAccount struct {
	Addr    string `json:"address"`
	Balance string `json:"balance"`
}

type CommitResult

type CommitResult struct {
	AppHash      []byte
	ReceiptsHash []byte
}

type ExecuteInvalidTx

type ExecuteInvalidTx struct {
	Bytes []byte
	Error error
}

type ExecuteResult

type ExecuteResult struct {
	ValidTxs   [][]byte
	InvalidTxs []ExecuteInvalidTx
	Error      error
}

type NewRoundResult

type NewRoundResult struct {
}

type QueryBase

type QueryBase struct {
	Order  string
	Limit  uint64
	Cursor uint64

	Begin uint64
	End   uint64
}

type Result

type Result struct {
	Code uint32 `json:"Code"`
	//Data []byte   `json:"Data"`
	Data []byte `json:"Data"`
	Log  string `json:"Log"` // Can be non-deterministic
}

CONTRACT: a zero Result is OK.

func NewError

func NewError(code uint32, log string) Result

func NewResult

func NewResult(code uint32, data []byte, log string) Result

func NewResultOK

func NewResultOK(data []byte, log string) Result

NOTE: if data == nil and log == "", same as zero Result.

func (Result) AppendLog

func (res Result) AppendLog(log string) Result

func (Result) Error

func (res Result) Error() string

func (*Result) FromJSON

func (res *Result) FromJSON(j string) *Result

func (Result) IsErr

func (res Result) IsErr() bool

func (Result) IsOK

func (res Result) IsOK() bool

func (Result) PrependLog

func (res Result) PrependLog(log string) Result

func (Result) SetData

func (res Result) SetData(data []byte) Result

func (Result) SetLog

func (res Result) SetLog(log string) Result

func (Result) String

func (res Result) String() string

func (Result) ToJSON

func (res Result) ToJSON() string

type Transaction

type Transaction struct {
	Type    uint8     //0-默认 1-special op
	Actions []*Action //有序的action 按照ID ASC序
}

通过Transaction 计算txhash

func (*Transaction) CheckSig

func (tx *Transaction) CheckSig() error

func (Transaction) Len

func (p Transaction) Len() int

func (Transaction) Less

func (p Transaction) Less(i, j int) bool

func (*Transaction) SigHash

func (tx *Transaction) SigHash() (h ethcmn.Hash)

SigHash Hash方法 本方法不能随意修改 因为Hash会变,链上也用的这个hash作为交易hash

func (*Transaction) Sign

func (tx *Transaction) Sign(privkeys []*ecdsa.PrivateKey) error

func (*Transaction) String

func (p *Transaction) String() string

func (Transaction) Swap

func (p Transaction) Swap(i, j int)

type TransactionData

type TransactionData struct {
	TxID        uint64         `json:"tx_id"`        //交易ID
	TxHash      ethcmn.Hash    `json:"tx_hash"`      //交易HASH - 重复交易不会被处理
	BlockHeight uint64         `json:"block_height"` //区块高度
	BlockHash   ethcmn.Hash    `json:"block_hash"`   //区块HASH
	ActionCount uint32         `json:"action_count"` //一笔交易多个action
	ActionID    uint32         `json:"action_id"`    //action id
	Src         ethcmn.Address `json:"src"`          //用户ID (if dir==0,uid 表示转入方,否则表示转出方)
	Dst         ethcmn.Address `json:"dst"`          //关联的用户ID
	Nonce       uint64         `json:"nonce"`        //对应操作源帐户(转出方)NONCE
	Amount      *big.Int       `json:"amount"`       //金额
	ResultCode  uint           `json:"result_code"`  //应答码 0-success
	ResultMsg   string         `json:"result_msg"`   //应答消息
	CreateAt    uint64         `json:"created_at"`   //入库时间
	JData       string         `json:"jdata"`        //数据部分 建议JSON序列化
	Memo        string         `json:"memo"`         //交易备注
}

TransactionData 交易表 一次HTTP请求算一笔交易,拥有唯一的交易HASH 单笔交易可以携带多个ACTION,每次ACTION有一个ID,ACTIONID由调用方指定,注意JSON Array没有顺序 每个ACTION保护出让方和受让方,“创建帐户”不是ACTION 单笔交易多个ACTION时可以部分失败,部分失败返回{成功的action列表,失败的action列表}

type TxQuery

type TxQuery struct {
	QueryBase
	TxHash    ethcmn.Hash
	Account   ethcmn.Address
	Direction uint8
}

type TxSignature

type TxSignature struct {
	Sig []byte
}

type Validator

type Validator struct {
	PubKey string //base64
	Power  int64
}

Jump to

Keyboard shortcuts

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