JSON RPC improvements
Method node_request
should validate request / response ID match.
Using ID = 1 in all JSON-RPC calls is antipattern.
IMO fixing responsibility boundaries should solve the issue and make calls waaaaay more simple:
method node_request (Str:D :$name, :$params = [] ) {
my $id = ("a".."z",0..9).flat.roll(32).join;
compose JSON with ID and protocol version inside
send
validate ID in response, throw exception if mismatched
return result
}
...
# sample call
method eth_coinbase returns Str {
self!node_request(method => "eth_coinbase")<result>;
}
My point is that request ID, response ID validation and JSON-RPC version are protool stuff and node_request
method callers should not know and should not care about it.
Edited by Pawel Pabian