From e1d0deecd8a5d5d9c9acf995f79bd4909e117139 Mon Sep 17 00:00:00 2001 From: 4tochka Date: Sun, 2 Jun 2019 13:59:06 +0400 Subject: [PATCH] connector --- pybtc/connector/connector.py | 7 ++++--- pybtc/connector/utxo.py | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pybtc/connector/connector.py b/pybtc/connector/connector.py index dc961cf..b175df1 100644 --- a/pybtc/connector/connector.py +++ b/pybtc/connector/connector.py @@ -432,9 +432,6 @@ class Connector: loading = "Loading ... " if self.cache_loading else "" if self.deep_synchronization: self.log.debug("-Blocks--------------------------------------------------------------------") - self.log.debug("Blocks downloaded %s s; decoded %s s" % (int(self.blocks_download_time), - int(self.blocks_decode_time))) - self.log.debug("Blocks not cached %s; " "blocks cached %s; " @@ -462,6 +459,9 @@ class Connector: self.utxo.saved_utxo, self.utxo.deleted_utxo, self.utxo.loaded_utxo)) + self.log.debug("Read from db last batch %s s; " + "total %s s; " % (round(self.utxo.read_from_db_time, 4), + int(self.utxo.read_from_db_time_total)) self.log.debug("-Coins--------------------------------------------------------------------") self.log.debug("Coins %s; destroyed %s; " "unspent %s; op_return %s;" % (self.coins, @@ -578,6 +578,7 @@ class Connector: tx["vIn"][i]["coin"] = inp["_a_"] c += 1 self.preload_cached_annihilated += 1 + self.preload_cached_total += 1 except: try: tx["vIn"][i]["coin"] = inp["_c_"] diff --git a/pybtc/connector/utxo.py b/pybtc/connector/utxo.py index 997a0cd..1a9f1eb 100644 --- a/pybtc/connector/utxo.py +++ b/pybtc/connector/utxo.py @@ -43,6 +43,8 @@ class UTXO(): self.deleted_utxo = 0 self.deleted_last_block = 0 self.deleted_utxo = 0 + self.read_from_db_time = 0 + self.read_from_db_time_total = 0 self.loaded_utxo = 0 self.destroyed_utxo = 0 self.destroyed_utxo_block = 0 @@ -193,6 +195,7 @@ class UTXO(): try: self.load_utxo_future = asyncio.Future() l = list(self.missed) + t = time.time() if self.db_type == "postgresql": async with self.db.acquire() as conn: rows = await conn.fetch("SELECT outpoint, " @@ -235,6 +238,8 @@ class UTXO(): for i in l: try: self.missed.remove(i) except: pass + self.read_from_db_time += time.time() - t + self.read_from_db_time_total += time.time() - t finally: