From e9e5471ad3feef085e202f1c42469b6252106f99 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 14 Apr 2022 15:12:06 -0400 Subject: [PATCH] fix cache --- scribe/db/db.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scribe/db/db.py b/scribe/db/db.py index 479325c..4324766 100644 --- a/scribe/db/db.py +++ b/scribe/db/db.py @@ -1013,7 +1013,7 @@ class HubDB: branch, root = self.merkle.branch_and_root( self.get_block_txs(tx_height), tx_pos ) - tx_infos[tx_hash_bytes[::-1].hex()] = None if not tx else tx.hex(), { + merkle = { 'block_height': tx_height, 'merkle': [ hash_to_hex_str(_hash) @@ -1021,6 +1021,9 @@ class HubDB: ], 'pos': tx_pos } + tx_infos[tx_hash_bytes[::-1].hex()] = None if not tx else tx.hex(), merkle + if tx_height > 0 and tx_height + 10 < self.db_height: + self._tx_and_merkle_cache[tx_hash_bytes[::-1].hex()] = tx, merkle await asyncio.sleep(0) if needed_mempool: for tx_hash_bytes, tx in zip(needed_mempool, await run_in_executor(