我有一个由3个orgs和两个频道组成的网络。
channelone:org1,org2,chaincode- fabcar
信道两种:org1,org3,链码- fabphone
我想用法布卡查询链码--法布卡电话。
发布于 2019-10-15 15:12:46
您可以使用stub.InvokeChaincode方法从另一个链码中调用-
response := stub.InvokeChaincode(chaincodeName, invokeArgs, channelName)
if response.Status != shim.OK {
return nil
}
return response.Payload
有关详细信息,请参阅- https://sourcegraph.com/github.com/hyperledger/fabric/-/blob/core/chaincode/shim/interfaces.go#L62:3
发布于 2020-04-12 06:48:02
如果您用javascript或typescript编写链码,您可以使用以下代码:
const args = [functionName, ...]
const result = await ctx.stub.invokeChaincode(chaincodeName, args, channelName)
return result.payload.toString('utf8')
发布于 2018-08-02 15:35:54
我认为这是不可能的。您只能在同一通道内调用链码函数。函数invokeChaincode使用与原始事务相同的事务上下文。查看一下https://github.com/hyperledger-archives/fabric/blob/master/core/chaincode/shim/chaincode.go
// InvokeChaincode locally calls the specified chaincode `Invoke` using the
// same transaction context; that is, chaincode calling chaincode doesn't
// create a new transaction message.
func (stub *ChaincodeStub) InvokeChaincode(chaincodeName string, function string,
args []string) ([]byte, error) {
return handler.handleInvokeChaincode(chaincodeName, function, args, stub.UUID)
}
// QueryChaincode locally calls the specified chaincode `Query` using the
// same transaction context; that is, chaincode calling chaincode doesn't
// create a new transaction message.
func (stub *ChaincodeStub) QueryChaincode(chaincodeName string, function string, args
[]string) ([]byte, error) {
return handler.handleQueryChaincode(chaincodeName, function, args, stub.UUID)
}
https://stackoverflow.com/questions/51630962
复制相似问题