跨链智能合约方法定义
方法名 |
说明 |
---|---|
preCommitSend |
在跨链资产交换发起方所属区块链上执行的预提交操作 |
preCommitRecv |
在跨链资产交换接收方所属区块链上执行的预提交操作 |
commitSend |
在跨链资产交换发起方所属区块链上执行的提交操作 |
commitRecv |
在跨链资产交换接收方所属区块链上执行的提交操作 |
rollbackSend |
在跨链资产交换发起方所属区块链上执行的回滚操作 |
rollbackRecv |
在跨链资产交换接收方所属区块链上执行的回滚操作 |
/* * Function name list of the TCS example chaincode * Note: the chaincode for TCS should have all of the functions below with the same function names */ const ( fromPreCommitFuncName = "preCommitSend" toPreCommitFuncName = "preCommitRecv" fromCommitFuncName = "commitSend" toCommitFuncName = "commitRecv" fromRollbackFuncName = "rollbackSend" toRollbackFuncName = "rollbackRecv" ) /* * Invoke is the entrance of the chaincode invoking */ func (t *TCSExampleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { fmt.Println("TCS Example Function Invoke") function, args := stub.GetFunctionAndParameters() if function == fromPreCommitFuncName { return t.preCommitSend(stub, args) } else if function == toPreCommitFuncName { return t.preCommitRecv(stub, args) } else if function == fromCommitFuncName { return t.commitSend(stub, args) } else if function == toCommitFuncName { return t.commitRecv(stub, args) } else if function == fromRollbackFuncName { return t.rollbackSend(stub, args) } else if function == toRollbackFuncName { return t.rollbackRecv(stub, args) } else if function == "query" { return t.query(stub, args) } else if function == "init" { return t.Init(stub) } return shim.Error("Invalid invoke function name. Expecting \"preCommitSend\" \"preCommitRev\" " + "\"commitSend\" \"commitRecv\" \"rollbackSend\" \"rollbackRecv\" \"query\", but got: " + function) }