From b4bca0bc9af128016efa42adaee0ea106ab54def Mon Sep 17 00:00:00 2001 From: shao1555 Date: Mon, 18 Dec 2017 15:33:48 +0900 Subject: [PATCH] add batch support for http client --- lib/ethereum/http_client.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ethereum/http_client.rb b/lib/ethereum/http_client.rb index b8a214d..b2244eb 100644 --- a/lib/ethereum/http_client.rb +++ b/lib/ethereum/http_client.rb @@ -28,7 +28,12 @@ def send_single(payload) end def send_batch(batch) - raise NotImplementedError + result = send_single(batch.to_json) + result = JSON.parse(result) + + # Make sure the order is the same as it was when batching calls + # See 6 Batch here http://www.jsonrpc.org/specification + return result.sort_by! { |c| c['id'] } end end