Closed rockfridrich closed 6 years ago
Hi,
There are ->sendAll(array $requests)
and ->sendAllAsync(array $requests)
methods that handle sending batches or requests at once, and handle the multiple responses for each request.
$requests = [
$client->request(123, 'get'),
$client->request(124, 'set'),
];
$responses = $client->sendAll($requests);
@h-bragg it is another scenario. I have described scenario in which library creates such JSON request. Example from Ethereum Geth JSON-RPC
[{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x0abdace70d3790235af448c88547603b945604ea","data":"0x70a082310000000000000000000000000ad9fb61a07bac25625382b63693644497f1b204"},"latest"],"id":"0x0abdace70d3790235af448c88547603b945604ea"},{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x0cf0ee63788a0849fe5297f3407f701e122cc023","data":"0x70a082310000000000000000000000000ad9fb61a07bac25625382b63693644497f1b204"},"latest"],"id":"0x0cf0ee63788a0849fe5297f3407f701e122cc023"},{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x0e0989b1f9b8a38983c2ba8053269ca62ec9b195","data":"0x70a082310000000000000000000000000ad9fb61a07bac25625382b63693644497f1b204"},"latest"],"id":"0x0e0989b1f9b8a38983c2ba8053269ca62ec9b195"}]
From what I can see, that data you provided fits into the api call that Harry is suggesting. eg.
$requests = [
$client->request(
'0x0abdace70d3790235af448c88547603b945604ea',
'eth_call',
[
[
'to' => '0x0abdace70d3790235af448c88547603b945604ea',
'data' => '0x70a082310000000000000000000000000ad9fb61a07bac25625382b63693644497f1b204'
],
'latest'
]
),
// More requests here
];
$responses = $client->sendAll($requests);
Are you able to explain why you think that data would not work?
In JSON-RPC specification you can send an array or request and receive an array of responses. In some scenarios, it may slightly increase performance in the library will send N asynced HTTP requests with M JSON-RPC requests in each.