diff --git a/server/db.py b/server/db.py index 6b71daf..bfe0b7e 100644 --- a/server/db.py +++ b/server/db.py @@ -26,11 +26,11 @@ UTXO_TX_HASH_LEN = 4 UTXO = namedtuple("UTXO", "tx_num tx_pos tx_hash height value") -def to_4_bytes(value): - return struct.pack(' self.next_cache_check: self.next_cache_check = now + 60 - if self.cache_MB() > self.flush_MB: - self.flush_all() + if self.cache_MB(daemon_height) > self.flush_MB: + self.flush_all(daemon_height) def process_tx(self, tx_hash, tx): cache = self.utxo_cache diff --git a/server/server.py b/server/server.py index 50a9e35..55ef6ab 100644 --- a/server/server.py +++ b/server/server.py @@ -64,11 +64,11 @@ class BlockCache(object): while not self.stop: await asyncio.sleep(1) while self.blocks: - self.db.process_block(self.blocks.pop()) + self.db.process_block(self.blocks.pop(), self.daemon_height) # Release asynchronous block fetching await asyncio.sleep(0) - self.db.flush() + self.db.flush_all(self.daemon_height) async def catch_up(self): self.logger.info('catching up, block cache limit {:d}MB...'