diff --git a/pybtc/connector/block_loader.py b/pybtc/connector/block_loader.py index b2fd47e..19874d2 100644 --- a/pybtc/connector/block_loader.py +++ b/pybtc/connector/block_loader.py @@ -73,11 +73,11 @@ class BlockLoader: if self.last_batch_size < 1000000 and self.rpc_batch_limit < 450: self.rpc_batch_limit += 50 self.log.warning("rpc batch limit %s " % self.rpc_batch_limit) - elif self.last_batch_size > 40000000 and self.rpc_batch_limit > 150: - self.rpc_batch_limit -= 50 + elif self.last_batch_size > 40000000 and self.rpc_batch_limit > 100: + self.rpc_batch_limit -= 40 self.log.warning("rpc batch limit %s " % self.rpc_batch_limit) - elif self.last_batch_size > 80000000 and self.rpc_batch_limit < 60: - self.rpc_batch_limit = 40 + elif self.last_batch_size > 80000000 and self.rpc_batch_limit < 100: + self.rpc_batch_limit = 20 self.log.warning("rpc batch limit %s " % self.rpc_batch_limit) for i in self.worker_busy: @@ -227,9 +227,9 @@ class Worker: self.loop.set_default_executor(ThreadPoolExecutor(20)) self.out_writer = out_writer self.in_reader = in_reader - self.coins = MRU(1000000) - self.destroyed_coins = MRU(1000000) - self.a_coins = MRU(1000000) + self.coins = MRU(4000000) + self.destroyed_coins = MRU(4000000) + self.a_coins = MRU(4000000) signal.signal(signal.SIGTERM, self.terminate) self.loop.create_task(self.message_loop()) self.loop.run_forever() @@ -260,6 +260,7 @@ class Worker: result = await self.rpc.batch(batch) break except: + self.log.critical(str(traceback.format_exc())) await asyncio.sleep(5) attempt -= 1 if not attempt: diff --git a/pybtc/connector/connector.py b/pybtc/connector/connector.py index ad2542f..b45ed6c 100644 --- a/pybtc/connector/connector.py +++ b/pybtc/connector/connector.py @@ -90,7 +90,8 @@ class Connector: self.preload_cached = 0 self.preload_cached_annihilated = 0 self.start_time = time.time() - + self.total_received_tx_last = 0 + self.start_time_last = time.time() # cache and system self.block_preload_cache_limit = block_preload_cache_limit self.block_hashes_cache_limit = block_hashes_cache_limit @@ -424,10 +425,13 @@ class Connector: 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: self.total_received_tx_stat = self.total_received_tx - self.log.info("Blocks %s; tx rate: %s;" % (block["height"], tx_rate)) + self.log.info("Blocks %s; tx rate: %s; [%s]" % (block["height"], tx_rate, tx_rate_last)) if self.utxo_data: loading = "Loading ... " if self.cache_loading else "" if self.deep_synchronization: