Tej*_*ale 8 hyperledger hyperledger-fabric
我想从Fabric 1.0中的另一个链代码调用一个链代码,所以我有一些问题:1)我们可以在单个对等端安装两个链代码2)如果我们在不同的对等端安装两个链代码,我们如何将一个代码调用到另一个?3)如果有样品示例请分享.
Art*_*ger 13
这应该是非常直接的实现,这是一个例子:
// Invoke
func (am *accountManagement) Invoke(stub shim.ChaincodeStubInterface) peer.Response {
actionName, params := stub.GetFunctionAndParameters()
if actionName == "callAnotherCC" {
chainCodeArgs := util.ToChaincodeArgs("anotherCCFunc", "paramA")
response := stub.InvokeChaincode("anotherCCName", chainCodeArgs, "channelName")
if response.Status != shim.OK {
return shim.Error(response.Message)
}
return shim.Success(nil)
}
// NOTE: This is an example, hence assuming only valid call is to call another chaincode
return shim.Error(fmt.Sprintf("[ERROR] No <%s> action defined", actionName))
}
Run Code Online (Sandbox Code Playgroud)
正如@Gari,在评论中正确陈述:
确保在每个认可对等体上安装两个链代码非常重要
考虑阅读以下材料:
| 归档时间: |
|
| 查看次数: |
2630 次 |
| 最近记录: |