Open jordaaash opened 4 years ago
Relevant: https://github.com/tendermint/go-amino/issues/301 - "The binary and json were intentionally written to mirror the code structure, so this kind of translation is easy."
Given the current impl, the divergence in JSON hints at divergence in function, whereby this optimization doesn't work for embedded structs (whereas such does work for json). In #301 what I want to convey is that we should continue to maintain code structure parity between binary and json, so that we solve common issues for both and reduce potential bugs. Once the implementations diverge, it will become difficult or impossible to keep in sync.
Anyways, great case study; thank you for the PR.
This PR provides a mechanism to completely override the Amino encoding of a type by implementing the
BinaryMarshaler
andBinaryUnmarshaler
interfaces.Amino prefix bytes will still be prepended. Implementing
MarshalAmino
/UnmarshalAmino
is not required. This should unblock https://github.com/tendermint/tendermint/pull/4245