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