Documentation ¶
Index ¶
- func Extends2Byte(ext []tcommon.KVPair) (ret []byte)
- func RegisterCodec(cdc *go_amino.Codec)
- func Sig2Byte(sgn Signature) (ret []byte)
- type ITx
- type QcpTxResult
- func (tx *QcpTxResult) CalcGas() types.BigInt
- func (tx *QcpTxResult) Exec(ctx context.Context) (result types.Result, crossTxQcps *TxQcp)
- func (tx *QcpTxResult) GetGasPayer() types.Address
- func (tx *QcpTxResult) GetSignData() []byte
- func (tx *QcpTxResult) GetSigner() []types.Address
- func (tx *QcpTxResult) IsOk() bool
- func (tx *QcpTxResult) ValidateData(ctx context.Context) error
- type Signature
- type TxQcp
- type TxStd
- func (tx *TxStd) BuildSignatureBytes(nonce int64, fromChainID string) []byte
- func (tx *TxStd) GetSigners() []types.Address
- func (tx *TxStd) SignTx(privkey crypto.PrivKey, nonce int64, fromChainID, toChainID string) (signedbyte []byte, err error)
- func (tx *TxStd) Type() string
- func (tx *TxStd) ValidateBasicData(ctx context.Context, isCheckTx bool, currentChaindID string) (err types.Error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extends2Byte ¶
功能:将common.KVPair转化成[]byte todo: test(amino序列化及反序列化的正确性)
func RegisterCodec ¶
Types ¶
type ITx ¶
type ITx interface { ValidateData(ctx context.Context) error //检测 //执行业务逻辑, // crossTxQcp: 需要进行跨链处理的TxQcp。 // 业务端实现中crossTxQcp只需包含`to` 和 `txStd` Exec(ctx context.Context) (result types.Result, crossTxQcp *TxQcp) GetSigner() []types.Address //签名者 CalcGas() types.BigInt //计算gas GetGasPayer() types.Address //gas付费人 GetSignData() []byte //获取签名字段 }
功能:抽象具体的Tx结构体
type QcpTxResult ¶
type QcpTxResult struct { Result types.Result `json:"result"` //对应TxQcp执行结果 QcpOriginalSequence int64 `json:"qcporiginalsequence"` //此结果对应的TxQcp.Sequence QcpOriginalExtends string `json:"qcpextends"` //此结果对应的 TxQcp.Extends Info string `json:"info"` //结果信息 }
qos端对TxQcp的执行结果
func NewQcpTxResult ¶
func NewQcpTxResult(result types.Result, qcpSequence int64, qcpExtends, info string) *QcpTxResult
功能:构建 QcpTxReasult 结构体
func (*QcpTxResult) CalcGas ¶
func (tx *QcpTxResult) CalcGas() types.BigInt
功能:计算gas 备注:暂返回0,后期可根据实际情况调整
func (*QcpTxResult) GetGasPayer ¶
func (tx *QcpTxResult) GetGasPayer() types.Address
功能:获取gas付费人 备注:返回空(因暂时gas为0,无人需要付gas)
func (*QcpTxResult) GetSigner ¶
func (tx *QcpTxResult) GetSigner() []types.Address
功能:获取签名者 备注:qos对QcpTxResult不做签名,故返回空
func (*QcpTxResult) IsOk ¶ added in v0.0.2
func (tx *QcpTxResult) IsOk() bool
func (*QcpTxResult) ValidateData ¶
func (tx *QcpTxResult) ValidateData(ctx context.Context) error
功能:检测结构体字段的合法性
type Signature ¶
type Signature struct { Pubkey crypto.PubKey `json:"pubkey"` //可选 Signature []byte `json:"signature"` //签名内容 Nonce int64 `json:"nonce"` //nonce的值 }
签名结构体
type TxQcp ¶
type TxQcp struct { TxStd *TxStd `json:"txstd"` //TxStd结构 From string `json:"from"` //qscName To string `json:"to"` //qosName Sequence int64 `json:"sequence"` //发送Sequence Sig Signature `json:"sig"` //签名 BlockHeight int64 `json:"blockheight"` //Tx所在block高度 TxIndex int64 `json:"txindex"` //Tx在block的位置 IsResult bool `json:"isresult"` //是否为Result Extends string `json:"extends"` //扩展字段 }
功能:
func NewTxQCP ¶
func NewTxQCP(txStd *TxStd, from string, to string, seqence int64, blockheigh int64, txindex int64, isResult bool, extends string) (rTx *TxQcp)
构建TxQCP结构体
func (*TxQcp) BuildSignatureBytes ¶ added in v0.0.7
type TxStd ¶
type TxStd struct { ITxs []ITx `json:"itx"` //ITx接口,将被具体Tx结构实例化 Signature []Signature `json:"sigature"` //签名数组 ChainID string `json:"chainid"` //ChainID: 执行ITx.exec方法的链ID MaxGas types.BigInt `json:"maxgas"` //Gas消耗的最大值 }
标准Tx结构体
func (*TxStd) BuildSignatureBytes ¶ added in v0.0.7
BuildSignatureBytes 生成待签名字节切片. nonce: account nonce + 1 currentChainID: 当前链chainID
func (*TxStd) GetSigners ¶ added in v0.0.8
Click to show internal directories.
Click to hide internal directories.