Practise optimism like before
This commit is contained in:
parent
311f7f9ffd
commit
f98dc9c351
@ -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('<I', db_value[n+21:n+25])
|
||||
hash, height = self.get_tx_hash(tx_num)
|
||||
if hash == tx_hash:
|
||||
self.db_deletes += 1
|
||||
match = db_value[n:n+25]
|
||||
# Remove the UTXO from both tables
|
||||
self.db_cache[db_key] = db_value[:n] + db_value[n + 25:]
|
||||
|
||||
db_key = b'u' + match + idx_packed
|
||||
utxo_value_packed = self.db.get(db_key)
|
||||
udb_key = b'u' + match + idx_packed
|
||||
utxo_value_packed = self.db.get(udb_key)
|
||||
if utxo_value_packed:
|
||||
self.db_cache[db_key] = None
|
||||
# Remove the UTXO from both tables
|
||||
self.db_deletes += 1
|
||||
self.db_cache[db_key] = db_value[:n] + db_value[n + 25:]
|
||||
self.db_cache[udb_key] = None
|
||||
return match + utxo_value_packed
|
||||
|
||||
# Uh-oh, this should not happen...
|
||||
|
||||
@ -210,12 +210,12 @@ class DB(LoggedClass):
|
||||
assert len(db_value) % 25 == 0
|
||||
|
||||
# Find which entry, if any, the TX_HASH matches.
|
||||
for n in range(0, len(data), 25):
|
||||
tx_num_packed = data[n + 21: n + 25]
|
||||
for n in range(0, len(db_value), 25):
|
||||
tx_num_packed = db_value[n + 21: n + 25]
|
||||
tx_num, = unpack('<I', tx_num_packed)
|
||||
hash, height = self.fs_tx_hash(tx_num)
|
||||
if hash == tx_hash:
|
||||
return data[n:n+21], tx_num_packed
|
||||
return db_value[n:n+21], tx_num_packed
|
||||
|
||||
return None, None
|
||||
|
||||
@ -230,7 +230,7 @@ class DB(LoggedClass):
|
||||
if not hash168:
|
||||
# This can happen when the daemon is a block ahead of us
|
||||
# and has mempool txs spending new txs in that block
|
||||
raise MissingUTXOError
|
||||
raise self.MissingUTXOError
|
||||
|
||||
key = b'u' + hash168 + tx_num_packed + idx_packed
|
||||
db_value = self.db.get(key)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user