event

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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

func EventKey(eventName, contractName, chainRid string) []byte

EventKey 生成eventKey

@param eventName
@param contractName
@param chainRid
@return []byte

func GetCommitParam

func GetCommitParam(chainRID string, proveStatus, contractStatus int, contractResult string) string

GetCommitParam 获取提交参数

@param chainRID
@param proveStatus
@param contractStatus
@param contractResult
@return string

func InitEventManager

func InitEventManager()

InitEventManager 初始化跨链触发器

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) Len

func (c *ChainTxContexts) Len() int

Len 获取长度

@receiver c
@return int

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 跨链事件内容

func (*EventInfo) ToString

func (e *EventInfo) ToString() string

ToString 转为string展示

@receiver e
@return string

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

func (*EventManager) SetEventState

func (e *EventManager) SetEventState(crossChainEventId string, state bool, stateMessages string) error

SetEventState 设置event状态

@receiver e
@param crossChainEventId
@param state
@param stateMessages
@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对象

func NewKeyValue

func NewKeyValue(key, value string) *KeyValue

NewKeyValue 新建kv对象

@param key
@param value
@return *KeyValue

func NewKeyValueByString

func NewKeyValueByString(data string) *KeyValue

NewKeyValueByString 通过字符串新建kv对象

@param data
@return *KeyValue

func (*KeyValue) Key

func (kv *KeyValue) Key() string

Key 获取key值

@receiver kv
@return string

func (*KeyValue) Value

func (kv *KeyValue) Value() string

Value 获取value值

@receiver kv
@return string

type KeyValues

type KeyValues struct {
	// contains filtered or unexported fields
}

KeyValues kv对象

func NewKeyValues

func NewKeyValues() *KeyValues

NewKeyValues 新建kv对象

@return *KeyValues

func NewNewKeyValuesByString

func NewNewKeyValuesByString(data string) *KeyValues

NewNewKeyValuesByString 通过字符串创建kev对象

@param data
@return *KeyValues

func (*KeyValues) Append

func (kvs *KeyValues) Append(kv *KeyValue)

Append 追加kev对象

@receiver kvs
@param kv

func (*KeyValues) Length

func (kvs *KeyValues) Length() int

Length 获取kv的长度

@receiver kvs
@return int

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

Jump to

Keyboard shortcuts

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