duangan6133 2018-10-04 16:55
浏览 1110
已采纳

Hyperledger Fabric链码-无法使用InvokeChaincode从另一个链码读取数据。 状态200,但有效载荷为空

I am working on a chaincode where I need to read data previously stored from another one.

They are instantiated on the same channel and I can use them individually to read and write data separately.

You can replicate it using the marble chaincode, installing it with different names on the same peer.

In one of them (A) I implemented invokeChaincode(B), to read data stored by B in this way:

func (chaincode *SimpleChaincode) queryMarblesFromAnotherChaincode(stub shim.ChaincodeStubInterface, args []string) peer.Response {

    queryMarble := "queryMarble"

    if len(args) != 3 {
        return shim.Error("Incorrect number of arguments. Expecting 3")
    }

    chaincodeName := args[0]
    chaincodeArgs := toChaincodeArgs(queryMarble, args[1])
    chaincodeChannel := args[2]

    response := stub.InvokeChaincode(chaincodeName, chaincodeArgs, chaincodeChannel)
    if response.Status != shim.OK {
        return shim.Error(fmt.Sprintf("Failed to query chaincode: %s", response.Payload))
    }
    return shim.Success(response.Payload)
}

Running that method using peer chaincode invoke .. , I receive status: 200, but Payload is empty.

Could you advise on what I am doing wrong?

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 CygwinPortable 中 NumPy 无法安装
      • ¥15 51单片机 用汇编语言实现方波非1:1的输出
      • ¥15 vivado如何支持多维打包数组模式
      • ¥15 请问第13题到底应该怎么做
      • ¥15 stable diffusion报错问题
      • ¥20 数据可视化综合运用 导入npz文件以及读取内容
      • ¥15 倒计时汇编语言RTC实时时钟
      • ¥15 CCS安装出现Failed to create the part's controls
      • ¥15 请问有digital Fortran编译器吗
      • ¥15 用cst怎么仿真同轴馈线