koinos / koinos-types

The Rosetta Stone of the Koinos ecosystem. Allows for the interpretation of Koinos data structures in a multitude of languages. Useful in the development of microservices, clients, and smart contracts.
MIT License
12 stars 3 forks source link

Multihash JSON serialization #153

Closed theoreticalbts closed 3 years ago

theoreticalbts commented 3 years ago

JSON serialization of multihash should be overridden. Currently this C++ code:

   LOG(info) << "Applying block - height: " << block.submission.topology.height
      << ", id: " << block.submission.topology.id;

produces this output:

2021-03-19 04:08:05.824873 [reqhandler.cpp:307] <info>: Applying block - height: 1, id: {"digest":"zJ5yH3KPx14JBLqG9Zssm2iBiQBkpDm8eCxcqsLkCTpxL","hash":18}

Expected output is something along the lines of:

2021-03-19 04:08:05.824873 [reqhandler.cpp:307] <info>: Applying block - height: 1, id: "z..."

where ... is the serialization of 18 followed by the bytes represented by the original string zJ5yH3KPx14JBLqG9Zssm2iBiQBkpDm8eCxcqsLkCTpxL

All serializations / deserializations on all targets should implement the same behavior.

theoreticalbts commented 3 years ago

We should check the serialization against the libp2p implementation of multibase / multihash.

theoreticalbts commented 3 years ago

We've decided to change the variable_blob serialization as well. Editing title and OP to properly describe the new scope.