From d11c60f6adf9c77767c97c45eec5e66627f8505f Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Tue, 11 Oct 2016 06:43:59 +0900 Subject: [PATCH] Cache size logging --- server/db.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/server/db.py b/server/db.py index 2e4f619..3625e88 100644 --- a/server/db.py +++ b/server/db.py @@ -95,10 +95,6 @@ class UTXOCache(object): self.cache_hits = 0 self.db_deletes = 0 - def size_MB(self): - '''Returns the approximate size of the cache, in MB.''' - return (len(self.cache) + len(self.db_cache)) * 100 // 1048576 - def add_many(self, tx_hash, tx_num, txouts): '''Add a sequence of UTXOs to the cache, return the set of hash168s seen. @@ -122,8 +118,8 @@ class UTXOCache(object): hash168s.add(hash168) key = tx_hash + pack(' self.flush_MB: + if self.cache_MB() > self.flush_MB: self.flush() def process_tx(self, tx_hash, tx):