stdrpc
stdrpc copied to clipboard
Batch Requests
https://bitcoin.stackexchange.com/a/38492
Allow input like:
[{"jsonrpc":"2.0","method":"x","params":"y","id":1545344929685}, {"jsonrpc":"2.0","method":"a","params":"b","id":1545344929686}]
From https://www.jsonrpc.org/specification#batch:
rpc call Batch:
--> [
{"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"},
{"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},
{"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"},
{"foo": "boo"},
{"jsonrpc": "2.0", "method": "foo.get", "params": {"name": "myself"}, "id": "5"},
{"jsonrpc": "2.0", "method": "get_data", "id": "9"}
]
<-- [
{"jsonrpc": "2.0", "result": 7, "id": "1"},
{"jsonrpc": "2.0", "result": 19, "id": "2"},
{"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request"}, "id": null},
{"jsonrpc": "2.0", "error": {"code": -32601, "message": "Method not found"}, "id": "5"},
{"jsonrpc": "2.0", "result": ["hello", 5], "id": "9"}
]
@ch4ot1c What kinda API would work for this?
something like?
const [ result1, result2 ] = await rpc.$batch()
.rpcCall1(arg)
.rpcCall2(arg)
.$exec();
Looks good