mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
btcproxy: Unpack batched JSON-RPC calls and issue them separately
This commit is contained in:
parent
88186020e0
commit
74f228deb8
1 changed files with 11 additions and 2 deletions
|
@ -31,8 +31,7 @@ class ProxiedBitcoinD(BitcoinD):
|
||||||
self.proxyport = proxyport
|
self.proxyport = proxyport
|
||||||
self.mocks = {}
|
self.mocks = {}
|
||||||
|
|
||||||
def proxy(self):
|
def _handle_request(self, r):
|
||||||
r = json.loads(request.data.decode('ASCII'))
|
|
||||||
conf_file = os.path.join(self.bitcoin_dir, 'bitcoin.conf')
|
conf_file = os.path.join(self.bitcoin_dir, 'bitcoin.conf')
|
||||||
brpc = BitcoinProxy(btc_conf_file=conf_file)
|
brpc = BitcoinProxy(btc_conf_file=conf_file)
|
||||||
method = r['method']
|
method = r['method']
|
||||||
|
@ -55,6 +54,16 @@ class ProxiedBitcoinD(BitcoinD):
|
||||||
"error": e.error,
|
"error": e.error,
|
||||||
"id": r['id']
|
"id": r['id']
|
||||||
}
|
}
|
||||||
|
return reply
|
||||||
|
|
||||||
|
def proxy(self):
|
||||||
|
r = json.loads(request.data.decode('ASCII'))
|
||||||
|
|
||||||
|
if isinstance(r, list):
|
||||||
|
reply = [self._handle_request(subreq) for subreq in r]
|
||||||
|
else:
|
||||||
|
reply = self._handle_request(subreq)
|
||||||
|
|
||||||
return json.dumps(reply, cls=DecimalEncoder)
|
return json.dumps(reply, cls=DecimalEncoder)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue