rpc: simplify the encoding of interface-typed arguments in JSON#7600
Merged
creachadair merged 7 commits intomasterfrom Jan 15, 2022
Merged
rpc: simplify the encoding of interface-typed arguments in JSON#7600creachadair merged 7 commits intomasterfrom
creachadair merged 7 commits intomasterfrom
Conversation
2175ab2 to
dd9fd5e
Compare
Author
|
I apparently missed a case in the e2e test, working on that. |
tychoish
reviewed
Jan 14, 2022
82354db to
bf10987
Compare
tychoish
approved these changes
Jan 14, 2022
added 4 commits
January 14, 2022 13:39
This implements a subset of the custom libs/json package, specifically it handles encoding and decoding of interface types wrapped in "tagged" JSON objects. It omits the deep reflection on arbitrary types, preserving only the handling of type tags wrapper encoding.
- Extend the Evidence interface to require support for tagged encoding. - Update the existing implementations to satisfy the type. - Register those types with the jsontypes registry. - Add string tags to 64-bit integer fields where needed.
bf10987 to
e3e4a83
Compare
8aa7ef8 to
514800a
Compare
b2ae00d to
08f44bf
Compare
bcd26e7 to
955945c
Compare
3 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new package
internal/jsontypesthat implements a subset of the behaviour defined in the customlibs/json(a.k.a.tmjson) package. Specifically, this new package implements the tag type registry used to map concrete types to interfaces, but omits all the recursive reflection. The new package handles only the packaging and decoding of "type wrapper" objects, using the same format as the original code.Apply this package to encode the parameters to the
broadcast_evidencecall in the JSON-RPC client. This case was explicitly skipped in #7552.For now, this change only affects the "encoding" side. The server decoding code is still using
tmjson, but I will update that in future PRs by applying similar treatment to the handful of other types (e.g., GenesisDoc) that traffic in interface fields.