JSON results are returned with HTTP status 500

This commit is contained in:
Neil Booth 2017-01-17 07:23:58 +09:00
parent c958b3af49
commit 5abe4faa8d
2 changed files with 5 additions and 2 deletions

View File

@ -22,7 +22,7 @@ from lib.jsonrpc import JSONRPC, RPCError, RequestBase
from lib.hash import sha256, double_sha256, hash_to_str, hex_str_to_hash from lib.hash import sha256, double_sha256, hash_to_str, hex_str_to_hash
import lib.util as util import lib.util as util
from server.block_processor import BlockProcessor from server.block_processor import BlockProcessor
from server.daemon import Daemon from server.daemon import Daemon, DaemonError
from server.irc import IRC from server.irc import IRC
from server.session import LocalRPC, ElectrumX from server.session import LocalRPC, ElectrumX
from server.mempool import MemPool from server.mempool import MemPool

View File

@ -70,7 +70,10 @@ class Daemon(util.LoggedClass):
async with self.workqueue_semaphore: async with self.workqueue_semaphore:
url = self.urls[self.url_index] url = self.urls[self.url_index]
async with aiohttp.post(url, data=data) as resp: async with aiohttp.post(url, data=data) as resp:
if resp.status == 200: # If bitcoind can't find a tx, for some reason
# it returns 500 but fills out the JSON.
# Should still return 200 IMO.
if resp.status in (200, 500):
if self.prior_msg: if self.prior_msg:
self.logger.info('connection restored') self.logger.info('connection restored')
result = processor(await resp.json()) result = processor(await resp.json())