typing and fix error string
This commit is contained in:
parent
bf539d67ea
commit
287ff0a557
2 changed files with 7 additions and 4 deletions
|
@ -550,7 +550,7 @@ class BlockProcessor:
|
||||||
self.claim_hash_to_txo[claim_hash] = (tx_num, nout)
|
self.claim_hash_to_txo[claim_hash] = (tx_num, nout)
|
||||||
self.db_op_stack.extend(pending.get_add_claim_utxo_ops())
|
self.db_op_stack.extend(pending.get_add_claim_utxo_ops())
|
||||||
|
|
||||||
def _add_support(self, txo: 'Output', tx_num: int, nout: int) -> List['RevertableOp']:
|
def _add_support(self, txo: 'Output', tx_num: int, nout: int):
|
||||||
supported_claim_hash = txo.claim_hash[::-1]
|
supported_claim_hash = txo.claim_hash[::-1]
|
||||||
self.support_txos_by_claim[supported_claim_hash].append((tx_num, nout))
|
self.support_txos_by_claim[supported_claim_hash].append((tx_num, nout))
|
||||||
self.support_txo_to_claim[(tx_num, nout)] = supported_claim_hash, txo.amount
|
self.support_txo_to_claim[(tx_num, nout)] = supported_claim_hash, txo.amount
|
||||||
|
@ -663,6 +663,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(
|
for k, claim_hash in self.db.db.iterator(
|
||||||
prefix=Prefixes.channel_to_claim.pack_partial_key(staged.claim_hash)):
|
prefix=Prefixes.channel_to_claim.pack_partial_key(staged.claim_hash)):
|
||||||
|
|
||||||
if claim_hash in self.abandoned_claims or claim_hash in self.expired_claim_hashes:
|
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)
|
||||||
|
@ -670,18 +671,20 @@ class BlockProcessor:
|
||||||
claim = self.txo_to_claim[self.claim_hash_to_txo[claim_hash]]
|
claim = self.txo_to_claim[self.claim_hash_to_txo[claim_hash]]
|
||||||
self.txo_to_claim[self.claim_hash_to_txo[claim_hash]] = StagedClaimtrieItem(
|
self.txo_to_claim[self.claim_hash_to_txo[claim_hash]] = StagedClaimtrieItem(
|
||||||
claim.name, claim.claim_hash, claim.amount, claim.expiration_height, claim.tx_num,
|
claim.name, claim.claim_hash, claim.amount, claim.expiration_height, claim.tx_num,
|
||||||
claim.position, claim.root_tx_num, claim.root_position, False,
|
claim.position, claim.root_tx_num, claim.root_position, channel_signature_is_valid=False,
|
||||||
claim.signing_hash, claim.reposted_claim_hash
|
signing_hash=claim.signing_hash, reposted_claim_hash=claim.reposted_claim_hash
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
claim = self.db.get_claim_txo(claim_hash)
|
claim = self.db.get_claim_txo(claim_hash)
|
||||||
assert claim is not None
|
assert claim is not None
|
||||||
signing_hash = Prefixes.channel_to_claim.unpack_key(k).signing_hash
|
signing_hash = Prefixes.channel_to_claim.unpack_key(k).signing_hash
|
||||||
self.db_op_stack.extend([
|
self.db_op_stack.extend([
|
||||||
|
# delete channel_to_claim/claim_to_channel
|
||||||
RevertableDelete(k, claim_hash),
|
RevertableDelete(k, claim_hash),
|
||||||
RevertableDelete(
|
RevertableDelete(
|
||||||
*Prefixes.claim_to_channel.pack_item(claim_hash, claim.tx_num, claim.position, signing_hash)
|
*Prefixes.claim_to_channel.pack_item(claim_hash, claim.tx_num, claim.position, signing_hash)
|
||||||
),
|
),
|
||||||
|
# update claim_to_txo with channel_signature_is_valid=False
|
||||||
RevertableDelete(
|
RevertableDelete(
|
||||||
*Prefixes.claim_to_txo.pack_item(
|
*Prefixes.claim_to_txo.pack_item(
|
||||||
claim_hash, claim.tx_num, claim.position, claim.root_tx_num, claim.root_position,
|
claim_hash, claim.tx_num, claim.position, claim.root_tx_num, claim.root_position,
|
||||||
|
|
|
@ -115,7 +115,7 @@ class RevertableOpStack:
|
||||||
# check that a delete for the stored value is in the stack
|
# check that a delete for the stored value is in the stack
|
||||||
raise OpStackIntegrity(f"delete {op}")
|
raise OpStackIntegrity(f"delete {op}")
|
||||||
elif op.is_delete and not has_stored_val:
|
elif op.is_delete and not has_stored_val:
|
||||||
raise OpStackIntegrity("db op tries to delete nonexistent key: {op}")
|
raise OpStackIntegrity(f"db op tries to delete nonexistent key: {op}")
|
||||||
elif op.is_delete and stored_val != op.value:
|
elif op.is_delete and stored_val != op.value:
|
||||||
raise OpStackIntegrity(f"db op tries to delete with incorrect value: {op}")
|
raise OpStackIntegrity(f"db op tries to delete with incorrect value: {op}")
|
||||||
self._items[op.key].append(op)
|
self._items[op.key].append(op)
|
||||||
|
|
Loading…
Reference in a new issue