Fabric-sdk-jAVA #fabric-sdk-java


jeff.jo95z@...
 

Hi All,

How to decode the data from blocklistener? is it possible to decode the output from blockEvent.getBlock() ?
Attaching the file for the reference


Mark Lewis
 

The BlockEvent itself has lots of helpful accessor methods to help you navigate to useful data within the block, so you should probably prefer those if they do what you need. getBlock() returns the Block protobuf message, which is defined in the Fabric protocol buffer definitions:

https://github.com/hyperledger/fabric-protos/blob/9f95521bb870cca7b765217c80aeb600e0bd5abf/common/common.proto#L142-L146

The overall structure is quite complex, containing nested serialized protobuf messages. The Block object itself is a Java stub built from the protobuf definitions and contains methods to access data, so there is no need to "decode" it -- that has already been done. The protocol buffer documentation describes how the stubs packaged in fabric-sdk-java relate to the protocol buffer definitions and the API they provide:

https://developers.google.com/protocol-buffers/docs/javatutorial#the-protocol-buffer-api