From d10de7fa72ab3546107845b582fd80c163f4bdfa Mon Sep 17 00:00:00 2001 From: bitspill Date: Tue, 16 Oct 2018 14:27:23 -0700 Subject: [PATCH] Allow batch RPC calls --- lib/http/base.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/http/base.js b/lib/http/base.js index bb8c1ef0..cb463a1c 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -437,8 +437,15 @@ HTTPBase.prototype.jsonRPC = function jsonRPC(rpc) { if (req.pathname !== '/') return; - if (typeof req.body.method !== 'string') - return; + if (req.body instanceof Array) { + for (const request of req.body) { + if (typeof request.method !== 'string') + return; + } + } else { + if (typeof req.body.method !== 'string') + return; + } let json = await rpc.call(req.body, req.query);