From 320f5cebc7fee9a9e1b709cdbb91270395c2b44d Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 7 Oct 2019 01:26:40 -0300 Subject: [PATCH] cleanup --- torba/torba/client/baseledger.py | 14 ++++++-------- torba/torba/client/basenetwork.py | 1 - 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/torba/torba/client/baseledger.py b/torba/torba/client/baseledger.py index e19e4acbc..52e3b79ab 100644 --- a/torba/torba/client/baseledger.py +++ b/torba/torba/client/baseledger.py @@ -312,19 +312,17 @@ class BaseLedger(metaclass=LedgerRegistry): current = len(self.headers) get_chunk = partial(self.network.retriable_call, self.network.get_headers, count=4096, b64=True) chunks = [asyncio.ensure_future(get_chunk(height)) for height in range(current, target, 4096)] - import time - start = time.time() total = 0 async with self.headers.checkpointed_connector() as connector: for chunk in chunks: headers = await chunk total += len(headers['base64']) - try: - connector.connect(len(self.headers), zlib.decompress(base64.b64decode(headers['base64']), wbits=-15, bufsize=600_000)) - except BaseException: - log.exception("ops") - log.info("Headers sync: %s / %s -- %s", connector.tell() // self.headers.header_size, target, total) - print(time.time() - start) + connector.connect( + len(self.headers), + zlib.decompress(base64.b64decode(headers['base64']), wbits=-15, bufsize=600_000) + ) + progress = connector.tell() // self.headers.header_size + log.info("Headers sync: %s / %s -- %s", progress, target, total) async def update_headers(self, height=None, headers=None, subscription_update=False): rewound = 0 diff --git a/torba/torba/client/basenetwork.py b/torba/torba/client/basenetwork.py index 77de1925e..b2a5b6878 100644 --- a/torba/torba/client/basenetwork.py +++ b/torba/torba/client/basenetwork.py @@ -1,6 +1,5 @@ import logging import asyncio -import zlib from operator import itemgetter from typing import Dict, Optional, Tuple from time import perf_counter