From 0922c7d3f4a10626ea5bb82ff6d7712310b7ace9 Mon Sep 17 00:00:00 2001 From: 4tochka Date: Mon, 3 Jun 2019 13:31:00 +0400 Subject: [PATCH] connector --- pybtc/connector/connector.py | 13 +++++++------ pybtc/connector/utxo.py | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pybtc/connector/connector.py b/pybtc/connector/connector.py index c49145e..7bd8feb 100644 --- a/pybtc/connector/connector.py +++ b/pybtc/connector/connector.py @@ -424,12 +424,12 @@ class Connector: for h in tx_bin_list: self.tx_cache.pop(h) - tx_rate = round(self.total_received_tx / (time.time() - self.start_time), 4) - tx_rate_last = round(self.total_received_tx_last / (time.time() - self.start_time_last), 4) - self.total_received_tx_last = 0 - self.start_time_last = time.time() t = 10000 if not self.deep_synchronization else 100000 if (self.total_received_tx - self.total_received_tx_stat) > t: + tx_rate = round(self.total_received_tx / (time.time() - self.start_time), 4) + tx_rate_last = round(self.total_received_tx_last / (time.time() - self.start_time_last), 4) + self.total_received_tx_last = 0 + self.start_time_last = time.time() self.total_received_tx_stat = self.total_received_tx self.log.info("Blocks %s; tx rate: %s; [%s]" % (block["height"], tx_rate, tx_rate_last)) if self.utxo_data: @@ -464,7 +464,8 @@ class Connector: self.utxo.deleted_utxo, self.utxo.loaded_utxo)) if self.utxo.read_from_db_time_total: - c = round(self.utxo.read_from_db_count / self.utxo.read_from_db_time_total, 4) + c = round(self.utxo.read_from_db_count + / (time.time() - self.utxo.read_from_db_batch_time), 4) else: c = 0 self.log.debug(" Read from db last batch %s; " @@ -474,7 +475,7 @@ class Connector: self.utxo.read_from_db_count, c, int(self.utxo.read_from_db_time_total))) - self.utxo.read_from_db_time = 0 + self.utxo.read_from_db_batch_time = time.time() self.utxo.read_from_db_count = 0 self.log.debug("- Coins ---------------") self.log.debug(" Coins %s; destroyed %s; " diff --git a/pybtc/connector/utxo.py b/pybtc/connector/utxo.py index 2574d5a..071b183 100644 --- a/pybtc/connector/utxo.py +++ b/pybtc/connector/utxo.py @@ -44,6 +44,7 @@ class UTXO(): self.deleted_last_block = 0 self.deleted_utxo = 0 self.read_from_db_time = 0 + self.read_from_db_batch_time = time.time() self.read_from_db_count = 0 self.read_from_db_time_total = 0 self.loaded_utxo = 0