From bc6c422e6d5d071a42f6fd6053276b7ce150014d Mon Sep 17 00:00:00 2001 From: 4tochka Date: Fri, 17 May 2019 19:59:31 +0400 Subject: [PATCH] connector --- pybtc/connector/block_loader.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pybtc/connector/block_loader.py b/pybtc/connector/block_loader.py index f5a7606..c31575b 100644 --- a/pybtc/connector/block_loader.py +++ b/pybtc/connector/block_loader.py @@ -219,6 +219,7 @@ class Worker: async def load_blocks(self, height): try: + attempt = 10 t = 0 start_height = height batch = list() @@ -237,7 +238,15 @@ class Worker: if r["result"] is not None: batch.append(["getblock", r["result"], 0]) h.append(lh) - result = await self.rpc.batch(batch) + while True: + try: + result = await self.rpc.batch(batch) + break + except: + await asyncio.sleep(5) + attempt -= 1 + if not attempt: + raise RuntimeError("Connect to bitcoind failed") blocks = dict() for x, y in zip(h, result):