fix mismatch in claim_to_txo<->txo_to_claim

This commit is contained in:
Jack Robison 2021-07-02 17:03:51 -04:00
parent cf66c2a1ee
commit 0c30838b25
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -258,6 +258,7 @@ class BlockProcessor:
self.pending_channels = {} self.pending_channels = {}
self.amount_cache = {} self.amount_cache = {}
self.expired_claim_hashes: Set[bytes] = set()
def claim_producer(self): def claim_producer(self):
if self.db.db_height <= 1: if self.db.db_height <= 1:
@ -669,7 +670,7 @@ class BlockProcessor:
if staged.name.startswith('@'): # abandon a channel, invalidate signatures if staged.name.startswith('@'): # abandon a channel, invalidate signatures
for k, claim_hash in self.db.db.iterator(prefix=Prefixes.channel_to_claim.pack_partial_key(staged.claim_hash)): for k, claim_hash in self.db.db.iterator(prefix=Prefixes.channel_to_claim.pack_partial_key(staged.claim_hash)):
if claim_hash in self.abandoned_claims: if claim_hash in self.abandoned_claims or claim_hash in self.expired_claim_hashes:
continue continue
self.signatures_changed.add(claim_hash) self.signatures_changed.add(claim_hash)
if claim_hash in self.claim_hash_to_txo: if claim_hash in self.claim_hash_to_txo:
@ -702,6 +703,7 @@ class BlockProcessor:
def _expire_claims(self, height: int): def _expire_claims(self, height: int):
expired = self.db.get_expired_by_height(height) expired = self.db.get_expired_by_height(height)
self.expired_claim_hashes.update(set(expired.keys()))
spent_claims = {} spent_claims = {}
ops = [] ops = []
for expired_claim_hash, (tx_num, position, name, txi) in expired.items(): for expired_claim_hash, (tx_num, position, name, txi) in expired.items():
@ -1291,6 +1293,7 @@ class BlockProcessor:
self.pending_channels.clear() self.pending_channels.clear()
self.amount_cache.clear() self.amount_cache.clear()
self.signatures_changed.clear() self.signatures_changed.clear()
self.expired_claim_hashes.clear()
# for cache in self.search_cache.values(): # for cache in self.search_cache.values():
# cache.clear() # cache.clear()