Documentation ¶
Index ¶
- Constants
- func BuildBeginCrossChainRequestFromTbis(event common.CrossChainEvent, eventInfo *EventInfo, log *zap.SugaredLogger, ...) (req *relay_chain.BeginCrossChainRequest, err error)
- func EventKey(eventName, contractName, chainRid string) []byte
- func GetCommitParam(chainRID string, proveStatus, contractStatus int, contractResult string) string
- func InitEventManager()
- type ChainTxContext
- type ChainTxContexts
- type CommitContract
- type ContractListenData
- type CrossSubEvent
- type EventInfo
- type EventManager
- func (e *EventManager) BuildCrossChainMsg(eventInfo *EventInfo) (req *relay_chain.BeginCrossChainRequest, err error)
- func (e *EventManager) DeleteEvent(event *common.CrossChainEvent) error
- func (e *EventManager) GetEvent(crossChainEventId string) ([]*common.CrossChainEvent, error)
- func (e *EventManager) SaveEvent(event *common.CrossChainEvent, isNew bool) error
- func (e *EventManager) SetEventState(crossChainEventId string, state bool, stateMessages string) error
- type InnerContract
- type KeyValue
- type KeyValues
- type TbisEventParser
Constants ¶
const ( // TbisFlag tbis协议标记 TbisFlag = "tbis" // SubSuccess tbis协议成功 SubSuccess = 1 // SubFailed tbis协议失败 SubFailed = 2 // SubResult tbis协议结果字段 SubResult = "sub_results" )
Variables ¶
This section is empty.
Functions ¶
func BuildBeginCrossChainRequestFromTbis ¶
func BuildBeginCrossChainRequestFromTbis(event common.CrossChainEvent, eventInfo *EventInfo, log *zap.SugaredLogger, gatewayId string) (req *relay_chain.BeginCrossChainRequest, err error)
BuildBeginCrossChainRequestFromTbis 生成跨链请求参数
@param event @param eventInfo @param log @param gatewayId @return req @return err
func EventKey ¶
EventKey 生成eventKey
@param eventName @param contractName @param chainRid @return []byte
func GetCommitParam ¶
GetCommitParam 获取提交参数
@param chainRID @param proveStatus @param contractStatus @param contractResult @return string
Types ¶
type ChainTxContext ¶
type ChainTxContext struct { ChainRID string ProveStatus int ContractStatus int ContractResult string }
ChainTxContext 某条链交易的处理上下文,含链资源ID/证明情况及合约结果
func NewChainTxContext ¶
func NewChainTxContext(chainRID string, proveStatus, contractStatus int, contractResult string) *ChainTxContext
NewChainTxContext 新建某条链交易的处理上下文
@param chainRID @param proveStatus @param contractStatus @param contractResult @return *ChainTxContext
func (*ChainTxContext) ToContractParam ¶
func (c *ChainTxContext) ToContractParam() string
ToContractParam 序列化为tbis协议参数
@receiver c @return string
type ChainTxContexts ¶
type ChainTxContexts struct {
Contexts []*ChainTxContext
}
ChainTxContexts 交易的处理上下文
func NewChainTxContexts ¶
func NewChainTxContexts() *ChainTxContexts
NewChainTxContexts 新建交易的处理上下文
@return *ChainTxContexts
func (*ChainTxContexts) Append ¶
func (c *ChainTxContexts) Append(chainTxCtx *ChainTxContext)
Append 追加
@receiver c @param chainTxCtx
func (*ChainTxContexts) ToContractParam ¶
func (c *ChainTxContexts) ToContractParam() string
ToContractParam 序列化为tbis协议参数
@receiver c @return string
type CommitContract ¶
type CommitContract struct { Identity string // 提交时的身份 Ctt *InnerContract ParamsFormat string // 参数格式化 ParamsData []string // 跨链事件写入的内容 ParamsContent string // 转换后的具体参数 }
CommitContract 提交的合约信息
func NewCommitContract ¶
func NewCommitContract(identity string, cttName, cttVersion, cttMethod string, cttExtraConf map[string]string, paramsFormat string, paramsData []string) *CommitContract
NewCommitContract 新建一个提交对象
@param identity @param cttName @param cttVersion @param cttMethod @param cttExtraConf @param paramsFormat @param paramsData @return *CommitContract
func NewEmptyCommitContract ¶
func NewEmptyCommitContract() *CommitContract
NewEmptyCommitContract 空的提交对象
@return *CommitContract
func (*CommitContract) Check ¶
func (c *CommitContract) Check() error
Check 检查内部参数,该类允许内部为空
@receiver c @return error
func (*CommitContract) CheckIdentity ¶
func (c *CommitContract) CheckIdentity(chainRID string) error
CheckIdentity 检查链身份
@receiver c @param ChainRID @return error
func (*CommitContract) GetParamsData ¶
func (c *CommitContract) GetParamsData() string
GetParamsData 获取参数
@receiver c @return string
type ContractListenData ¶
type ContractListenData struct { CrossID string // 跨链ID EventName string // 事件名称 EventData string // 事件数据 Business string // 跨链事件对应的业务关键字 CommitCtt *CommitContract SubEvents []*CrossSubEvent }
ContractListenData 由合约事件监听到的内容转换后获得
func NewEmptyContractListenData ¶
func NewEmptyContractListenData() *ContractListenData
NewEmptyContractListenData 新建一个空的listen数据
@return *ContractListenData
func (*ContractListenData) AppendSubEvent ¶
func (d *ContractListenData) AppendSubEvent(crossSubEvent *CrossSubEvent)
AppendSubEvent 添加SubEvent
@receiver d @param crossSubEvent
func (*ContractListenData) CheckAndInit ¶
func (d *ContractListenData) CheckAndInit() error
CheckAndInit 检查并初始化内部参数
@receiver d @return error
func (*ContractListenData) CheckAvailability ¶
func (d *ContractListenData) CheckAvailability(chainRID string) error
CheckAvailability 检查链签名身份可用性
@receiver d @param chainRID @return error
func (*ContractListenData) GetSubEvents ¶
func (d *ContractListenData) GetSubEvents() []*CrossSubEvent
GetSubEvents 返回subEvents
@receiver d @return []*CrossSubEvent
type CrossSubEvent ¶
type CrossSubEvent struct { ChainRID string GatewayID string ExecIdx int ChainCtt *CommitContract }
CrossSubEvent 子链跨链事件
func NewCrossSubEvent ¶
func NewCrossSubEvent(chainRID string, dstGatewayID string, chainCtt *CommitContract) *CrossSubEvent
NewCrossSubEvent 新建子事件
@param chainRID @param dstGatewayID @param chainCtt @return *CrossSubEvent
func NewEmptyCrossSubEvent ¶
func NewEmptyCrossSubEvent() *CrossSubEvent
NewEmptyCrossSubEvent 新建空的子事件
@return *CrossSubEvent
func (*CrossSubEvent) CheckAndInit ¶
func (se *CrossSubEvent) CheckAndInit() error
CheckAndInit 检查并初始化内部参数
@receiver se @return error
type EventInfo ¶
type EventInfo struct { Topic string ChainRid string ContractName string TxProve string Data []string Tx []byte TxId string BlockHeight int64 }
EventInfo 跨链事件内容
type EventManager ¶
type EventManager struct {
// contains filtered or unexported fields
}
EventManager 跨链触发器结构体
var EventManagerV1 *EventManager
EventManagerV1 跨链触发器
func (*EventManager) BuildCrossChainMsg ¶
func (e *EventManager) BuildCrossChainMsg(eventInfo *EventInfo) (req *relay_chain.BeginCrossChainRequest, err error)
BuildCrossChainMsg 创建跨链信息
@receiver e @param eventInfo @return req @return err
func (*EventManager) DeleteEvent ¶
func (e *EventManager) DeleteEvent(event *common.CrossChainEvent) error
DeleteEvent 删除event
@receiver e @param event @return error
func (*EventManager) GetEvent ¶
func (e *EventManager) GetEvent(crossChainEventId string) ([]*common.CrossChainEvent, error)
GetEvent 获取跨链事件
@receiver e @param crossChainEventId @return []*common.CrossChainEvent @return error
func (*EventManager) SaveEvent ¶
func (e *EventManager) SaveEvent(event *common.CrossChainEvent, isNew bool) error
SaveEvent 保存event
@receiver e @param event @param isNew @return error
type InnerContract ¶
type InnerContract struct { Name string // 合约名称 Version string // 合约版本号信息 Method string // 合约方法 ExtraData map[string]string // 扩展的一些数据,例如ABI }
InnerContract Inner Contract
func NewEmptyInnerContract ¶
func NewEmptyInnerContract() *InnerContract
NewEmptyInnerContract 新建新的内部合约对象
@return *InnerContract
func NewInnerContract ¶
func NewInnerContract(name, version, method string) *InnerContract
NewInnerContract 新建内部合约
@param name @param version @param method @return *InnerContract
func (*InnerContract) Abi ¶
func (c *InnerContract) Abi() (string, bool)
Abi 获取abi
@receiver c @return string @return bool
func (*InnerContract) GetExtraData ¶
func (c *InnerContract) GetExtraData() string
GetExtraData 获取扩展字段
@receiver c @return string
func (*InnerContract) Put ¶
func (c *InnerContract) Put(key, val string)
Put 设置key值
@receiver c @param key @param val
func (*InnerContract) PutBatch ¶
func (c *InnerContract) PutBatch(kvs map[string]interface{})
PutBatch 批量设置key值
@receiver c @param kvs
func (*InnerContract) Puts ¶
func (c *InnerContract) Puts(kvs map[string]string)
Puts 批量设置key值
@receiver c @param kvs
type KeyValue ¶
type KeyValue struct {
// contains filtered or unexported fields
}
KeyValue kv对象
type KeyValues ¶
type KeyValues struct {
// contains filtered or unexported fields
}
KeyValues kv对象
type TbisEventParser ¶
type TbisEventParser struct {
// contains filtered or unexported fields
}
TbisEventParser tbis事件解析器
func NewTbisEventParser ¶
func NewTbisEventParser(log *zap.SugaredLogger) *TbisEventParser
NewTbisEventParser 新建tbis事件解析器
func (*TbisEventParser) ParseListenEvent ¶
func (t *TbisEventParser) ParseListenEvent(chainRID, data string) (*ContractListenData, error)
ParseListenEvent 格式化事件
@receiver t @param chainRID @param data @return *ContractListenData @return error