Practise optimism like before
This commit is contained in:
parent
311f7f9ffd
commit
f98dc9c351
@ -249,7 +249,7 @@ class MemPool(LoggedClass):
|
|||||||
try:
|
try:
|
||||||
infos = (txin_info(txin) for txin in tx.inputs)
|
infos = (txin_info(txin) for txin in tx.inputs)
|
||||||
txin_pairs, unconfs = zip(*infos)
|
txin_pairs, unconfs = zip(*infos)
|
||||||
except MissingUTXOError:
|
except self.bp.MissingUTXOError:
|
||||||
# Drop this TX. If other mempool txs depend on it
|
# Drop this TX. If other mempool txs depend on it
|
||||||
# it's harmless - next time the mempool is refreshed
|
# it's harmless - next time the mempool is refreshed
|
||||||
# they'll either be cleaned up or the UTXOs will no
|
# they'll either be cleaned up or the UTXOs will no
|
||||||
@ -949,6 +949,19 @@ class BlockProcessor(server.db.DB):
|
|||||||
# Probably a strange UTXO
|
# Probably a strange UTXO
|
||||||
return NO_CACHE_ENTRY
|
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
|
assert len(db_value) % 25 == 0
|
||||||
|
|
||||||
# Find which entry, if any, the TX_HASH matches.
|
# 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])
|
tx_num, = unpack('<I', db_value[n+21:n+25])
|
||||||
hash, height = self.get_tx_hash(tx_num)
|
hash, height = self.get_tx_hash(tx_num)
|
||||||
if hash == tx_hash:
|
if hash == tx_hash:
|
||||||
self.db_deletes += 1
|
|
||||||
match = db_value[n:n+25]
|
match = db_value[n:n+25]
|
||||||
# Remove the UTXO from both tables
|
udb_key = b'u' + match + idx_packed
|
||||||
self.db_cache[db_key] = db_value[:n] + db_value[n + 25:]
|
utxo_value_packed = self.db.get(udb_key)
|
||||||
|
|
||||||
db_key = b'u' + match + idx_packed
|
|
||||||
utxo_value_packed = self.db.get(db_key)
|
|
||||||
if utxo_value_packed:
|
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
|
return match + utxo_value_packed
|
||||||
|
|
||||||
# Uh-oh, this should not happen...
|
# Uh-oh, this should not happen...
|
||||||
|
|||||||
@ -210,12 +210,12 @@ class DB(LoggedClass):
|
|||||||
assert len(db_value) % 25 == 0
|
assert len(db_value) % 25 == 0
|
||||||
|
|
||||||
# Find which entry, if any, the TX_HASH matches.
|
# Find which entry, if any, the TX_HASH matches.
|
||||||
for n in range(0, len(data), 25):
|
for n in range(0, len(db_value), 25):
|
||||||
tx_num_packed = data[n + 21: n + 25]
|
tx_num_packed = db_value[n + 21: n + 25]
|
||||||
tx_num, = unpack('<I', tx_num_packed)
|
tx_num, = unpack('<I', tx_num_packed)
|
||||||
hash, height = self.fs_tx_hash(tx_num)
|
hash, height = self.fs_tx_hash(tx_num)
|
||||||
if hash == tx_hash:
|
if hash == tx_hash:
|
||||||
return data[n:n+21], tx_num_packed
|
return db_value[n:n+21], tx_num_packed
|
||||||
|
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ class DB(LoggedClass):
|
|||||||
if not hash168:
|
if not hash168:
|
||||||
# This can happen when the daemon is a block ahead of us
|
# This can happen when the daemon is a block ahead of us
|
||||||
# and has mempool txs spending new txs in that block
|
# and has mempool txs spending new txs in that block
|
||||||
raise MissingUTXOError
|
raise self.MissingUTXOError
|
||||||
|
|
||||||
key = b'u' + hash168 + tx_num_packed + idx_packed
|
key = b'u' + hash168 + tx_num_packed + idx_packed
|
||||||
db_value = self.db.get(key)
|
db_value = self.db.get(key)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user