How parse qccc response data in java-sdk #fabric-sdk-java


Kumari Shweta
 

i am using the fabric-sdk-java 2.0 and trying to invoke the system chaincode `qscc` GetBlockByNumber.But the response is not in readable format.
How i can decode block in sdk java.

byte[] result= contract.evaluateTransaction("getBlockByNumber","channel",6);

Regards,
Shweta


David Faulstich Diniz Reis
 

i am using the fabric-sdk-java 2.0 and trying to invoke the system chaincode `qscc` GetBlockByNumber.But the response is not in readable format.
How i can decode block in sdk java.

byte[] result= contract.evaluateTransaction("getBlockByNumber","channel",6);

Regards,
Shweta




David Faulstich Diniz Reis
 

Sorry. Did you mean qscc.

Just a moment.

Em qua., 16 de mar. de 2022 às 13:41, David Faulstich <davidfdr@...> escreveu:


Em qua., 16 de mar. de 2022 às 09:42, Kumari Shweta via lists.hyperledger.org <kumari.shweta=hcl.com@...> escreveu:
i am using the fabric-sdk-java 2.0 and trying to invoke the system chaincode `qscc` GetBlockByNumber.But the response is not in readable format.
How i can decode block in sdk java.

byte[] result= contract.evaluateTransaction("getBlockByNumber","channel",6);

Regards,
Shweta



--



David Faulstich Diniz Reis
 

I did not find any easy sample to parse QSCC protobufs returns using java.

But I think you may use the following directions:

As soon as possible I will try to decode qscc using java sdk just to see how it works.


Today I use only javascript to decode protobufs from qscc. 

Good luck decoding qscc using java.


Best regards.

David

Em qua., 16 de mar. de 2022 às 13:42, David Faulstich <davidfdr@...> escreveu:

Sorry. Did you mean qscc.

Just a moment.

Em qua., 16 de mar. de 2022 às 13:41, David Faulstich <davidfdr@...> escreveu:

Em qua., 16 de mar. de 2022 às 09:42, Kumari Shweta via lists.hyperledger.org <kumari.shweta=hcl.com@...> escreveu:
i am using the fabric-sdk-java 2.0 and trying to invoke the system chaincode `qscc` GetBlockByNumber.But the response is not in readable format.
How i can decode block in sdk java.

byte[] result= contract.evaluateTransaction("getBlockByNumber","channel",6);

Regards,
Shweta



--


--



Mark Lewis
 

It returns a serialised Block protocol buffer message (see implementation). You should be able to deserialise it using the compiled protobuf implementations packaged in fabric-sdk-java. Something like:

Common.Block block = Common.Block.parseFrom(result);