|
|
@ -109,7 +109,7 @@ class UTXOCache(LoggedClass): |
|
|
|
return value |
|
|
|
|
|
|
|
# Oh well. Find and remove it from the DB. |
|
|
|
hash168 = self.hash168(prev_hash, idx_packed) |
|
|
|
hash168 = self.hash168(prev_hash, idx_packed, True) |
|
|
|
if not hash168: |
|
|
|
return NO_CACHE_ENTRY |
|
|
|
|
|
|
@ -144,7 +144,7 @@ class UTXOCache(LoggedClass): |
|
|
|
|
|
|
|
raise Exception('could not resolve UTXO key collision') |
|
|
|
|
|
|
|
def hash168(self, tx_hash, idx_packed): |
|
|
|
def hash168(self, tx_hash, idx_packed, delete=False): |
|
|
|
'''Return the hash168 paid to by the given TXO. |
|
|
|
|
|
|
|
Refers to the database. Returns None if not found (which is |
|
|
@ -158,7 +158,8 @@ class UTXOCache(LoggedClass): |
|
|
|
return None |
|
|
|
|
|
|
|
if len(data) == 25: |
|
|
|
self.cache_delete(key) |
|
|
|
if delete: |
|
|
|
self.cache_delete(key) |
|
|
|
return data[:21] |
|
|
|
|
|
|
|
assert len(data) % 25 == 0 |
|
|
@ -168,7 +169,8 @@ class UTXOCache(LoggedClass): |
|
|
|
(tx_num, ) = struct.unpack('<I', data[n+21:n+25]) |
|
|
|
my_hash, height = self.parent.get_tx_hash(tx_num) |
|
|
|
if my_hash == tx_hash: |
|
|
|
self.cache_write(key, data[:n] + data[n+25:]) |
|
|
|
if delete: |
|
|
|
self.cache_write(key, data[:n] + data[n+25:]) |
|
|
|
return data[n:n+21] |
|
|
|
|
|
|
|
raise Exception('could not resolve hash168 collision') |
|
|
|