Extending JSON RPC

155 views
Skip to first unread message

Mustafa Yelmer

unread,
Oct 8, 2023, 4:01:09 PM10/8/23
to JSON-RPC
Hello everyone

I'm developing a private blockchain structure which communicates with websocket (for gossip protocol, consensus, sync, business calls, etc, ...)
and another requirement is that message structure is JSON RPC

I have several questions and recommendations

1 - 
I need to extend the original structure for security (signature, digest, checksum etc)
By the way, I'm already using "id" field for custom values, ie: "[id];[hlc];[node-id];[version];..." but signature is special case, it should not be in other fields

2 -
I also need to extend error because I should also transfer some context values (correlation id, error fqdn, etc)  

3 - If the serialization is required by business owners
is there any option for it

4 - is version tag meaningful? or 
Is it JSON-RPC version or can I use it my version?

Note: "params of request" and "result of success response" can be JsonArray or JsonObject, I gave examples for only object

My sample cases

>>> {version: "2.0", signature: "...", id: "I'm using all custom values here", method: "topic-name", params: {...}}
<<< {version: "2.0", signature: "...", id: "...", result: {...}}
or
<<<  {version: "2.0", signature: "...", id: "...", error: {id: -1, message: "", details: ""}}

I would like to get recommendations
Thank you, and have a great day

Brad Jones

unread,
Oct 8, 2023, 5:26:45 PM10/8/23
to JSON-RPC
I think you're misunderstanding what JSON-RPC is and isn't about. JSON-RPC doesn't care at all about the structure of the data you return. It only concerns itself with the domain of the RPC call. If your data is representational and you're looking for an opinionated structure for JSON API calls, consider taking a look at JSON:API.

As the spec says, the version string is fixed. It sounds from this as though you need to put whatever required fields you have for your business rules inside the structure of the request and response data. You could write a spec for your users that expresses that, e.g. in json-schema.

Brad
Reply all
Reply to author
Forward
0 new messages