From f98dc9c3514a21fb24a4ca04a7c1d3d414ee8943 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 10 Nov 2016 21:22:58 +0900 Subject: [PATCH] Practise optimism like before --- server/block_processor.py | 28 ++++++++++++++++++++-------- server/db.py | 8 ++++---- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/server/block_processor.py b/server/block_processor.py index 67a9412..230c2de 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -249,7 +249,7 @@ class MemPool(LoggedClass): try: infos = (txin_info(txin) for txin in tx.inputs) txin_pairs, unconfs = zip(*infos) - except MissingUTXOError: + except self.bp.MissingUTXOError: # Drop this TX. If other mempool txs depend on it # it's harmless - next time the mempool is refreshed # they'll either be cleaned up or the UTXOs will no @@ -949,6 +949,19 @@ class BlockProcessor(server.db.DB): # Probably a strange UTXO return NO_CACHE_ENTRY + # FIXME: this matches what we did previously but until we store + # all UTXOs isn't safe + if len(db_value) == 25: + udb_key = b'u' + db_value + idx_packed + utxo_value_packed = self.db.get(udb_key) + if utxo_value_packed: + # Remove the UTXO from both tables + self.db_deletes += 1 + self.db_cache[db_key] = None + self.db_cache[udb_key] = None + return db_value + utxo_value_packed + # Fall through to below + assert len(db_value) % 25 == 0 # Find which entry, if any, the TX_HASH matches. @@ -956,15 +969,14 @@ class BlockProcessor(server.db.DB): tx_num, = unpack('