doutuo3575 2018-10-24 14:18
浏览 448

无法在Hyperledger Fabric Chaincode上的GetQueryResult(queryString)之后立即调用GetState

On my Fabric Golang chaincode, I need to find a list of object, then loop and call getState() on other objects on the ledger. It work with GetStateByRange(), but not with GetQueryResult(). All those are from shim.ChaincodeStubInterface

With GetQueryResult() I get a "No revision tag detected" after every getState()

Examples:

This works!

func (s *SmartContract) queryAllFormations(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {

                resultsIterator, _ := APIstub.GetStateByRange("FORM_1","FORM_99")
                for resultsIterator.HasNext() {
                    var formation Formation
                    json.Unmarshal(formationAsBytes.Value, &formation)
                    formationAsBytes, _:= resultsIterator.Next()
                    // Will succeed !
                    personAsBytes, _:= APIstub.GetState(formation.PersonID)
                    [...]
                 }
                 resultsIterator.Close()

This will fail!

func (s *SmartContract) queryAllFormations(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {
            queryString := ...
            resultsIterator, _ := APIstub.GetQueryResult(queryString)
            for resultsIterator.HasNext() {
                formationAsBytes, _:= resultsIterator.Next()
                var formation Formation
                json.Unmarshal(formationAsBytes.Value, &formation)
                // WILL fail
                personAsBytes, _:= APIstub.GetState(formation.PersonID)
                [...]
            }
            resultsIterator.Close()

error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: GET_STATE failed: transaction ID: 2117b32cc69873be0e752eb644250c4156f29d9ec48d385f88d43ca1705b909d: No revision tag detected at /home/apa/DEV/rinku/rinku-server/node_modules/fabric-client/lib/Peer.js:114:16 at /home/apa/DEV/rinku/rinku-server/node_modules/fabric-client/node_modules/grpc/src/client.js:586:7

Any idea ? Thanks in advance

  • 写回答

1条回答 默认 最新

  • dougou8639 2018-10-25 08:13
    关注

    As @DaveEnYeart dound out, some of my ID are empty.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据