This commit is contained in:
Jack Robison 2021-06-15 11:53:03 -04:00 committed by Victor Shyba
parent 066f797ad4
commit 531e6c1a61
2 changed files with 23 additions and 25 deletions

View file

@ -602,10 +602,10 @@ class BlockProcessor:
claim_name = ''.join(chr(c) for c in txo.script.values['claim_name'])
if txo.script.is_claim_name:
claim_hash = hash160(tx_hash + pack('>I', nout))[::-1]
print(f"\tnew lbry://{claim_name}#{claim_hash.hex()} ({tx_num} {txo.amount})")
# print(f"\tnew {claim_hash.hex()} ({tx_num} {txo.amount})")
else:
claim_hash = txo.claim_hash[::-1]
print(f"\tupdate lbry://{claim_name}#{claim_hash.hex()} ({tx_num} {txo.amount})")
# print(f"\tupdate {claim_hash.hex()} ({tx_num} {txo.amount})")
signing_channel_hash = None
channel_signature_is_valid = False
@ -663,10 +663,10 @@ class BlockProcessor:
root_tx_num, root_idx = tx_num, nout
else: # it's a claim update
if claim_hash not in spent_claims:
print(f"\tthis is a wonky tx, contains unlinked claim update {claim_hash.hex()}")
# print(f"\tthis is a wonky tx, contains unlinked claim update {claim_hash.hex()}")
return []
(prev_tx_num, prev_idx, _) = spent_claims.pop(claim_hash)
# print(f"\tupdate lbry://{claim_name}#{claim_hash.hex()} {tx_hash[::-1].hex()} {txo.amount}")
# print(f"\tupdate {claim_hash.hex()} {tx_hash[::-1].hex()} {txo.amount}")
if (prev_tx_num, prev_idx) in self.pending_claims:
previous_claim = self.pending_claims.pop((prev_tx_num, prev_idx))
root_tx_num, root_idx = previous_claim.root_claim_tx_num, previous_claim.root_claim_tx_position
@ -694,7 +694,7 @@ class BlockProcessor:
supported_claim_hash = txo.claim_hash[::-1]
self.pending_supports[supported_claim_hash].append((tx_num, nout))
self.pending_support_txos[(tx_num, nout)] = supported_claim_hash, txo.amount
print(f"\tsupport claim {supported_claim_hash.hex()} +{txo.amount}")
# print(f"\tsupport claim {supported_claim_hash.hex()} +{txo.amount}")
return StagedClaimtrieSupport(
supported_claim_hash, tx_num, nout, txo.amount
).get_add_support_utxo_ops()
@ -713,7 +713,7 @@ class BlockProcessor:
spent_support, support_amount = self.pending_support_txos.pop((txin_num, txin.prev_idx))
self.pending_supports[spent_support].remove((txin_num, txin.prev_idx))
supported_name = self._get_pending_claim_name(spent_support)
print(f"\tspent support for lbry://{supported_name}#{spent_support.hex()}")
# print(f"\tspent support for {spent_support.hex()}")
self.pending_removed_support[supported_name][spent_support].append((txin_num, txin.prev_idx))
return StagedClaimtrieSupport(
spent_support, txin_num, txin.prev_idx, support_amount
@ -726,7 +726,7 @@ class BlockProcessor:
activation = self.db.get_activation(txin_num, txin.prev_idx, is_support=True)
if activation <= self.height + 1:
self.removed_active_support[spent_support].append(support_amount)
print(f"\tspent support for lbry://{supported_name}#{spent_support.hex()} activation:{activation} {support_amount}")
# print(f"\tspent support for {spent_support.hex()} activation:{activation} {support_amount}")
ops = StagedClaimtrieSupport(
spent_support, txin_num, txin.prev_idx, support_amount
).get_spend_support_txo_ops()
@ -809,7 +809,7 @@ class BlockProcessor:
ops = []
for abandoned_claim_hash, (tx_num, nout, name) in spent_claims.items():
print(f"\tabandon lbry://{name}#{abandoned_claim_hash.hex()} {tx_num} {nout}")
# print(f"\tabandon {abandoned_claim_hash.hex()} {tx_num} {nout}")
ops.extend(self._abandon_claim(abandoned_claim_hash, tx_num, nout, name))
return ops
@ -921,7 +921,7 @@ class BlockProcessor:
controlling = get_controlling(staged.name)
if controlling and controlling.claim_hash == claim_hash:
names_with_abandoned_controlling_claims.append(staged.name)
print(f"\t{staged.name} needs takeover")
# print(f"\t{staged.name} needs takeover")
activation = self.db.get_activation(staged.tx_num, staged.position)
if activation > 0: # db returns -1 for non-existent txos
# removed queued future activation from the db
@ -985,7 +985,7 @@ class BlockProcessor:
for activated_txo in activated_txos:
if activated_txo.is_support and (activated_txo.tx_num, activated_txo.position) in \
self.pending_removed_support[activated.name][activated.claim_hash]:
print("\tskip activate support for pending abandoned claim")
# print("\tskip activate support for pending abandoned claim")
continue
if activated_txo.is_claim:
txo_type = ACTIVATED_CLAIM_TXO_TYPE
@ -1007,12 +1007,12 @@ class BlockProcessor:
activated.claim_hash, activated_txo.tx_num, activated_txo.position
)
if amount is None:
print("\tskip activate support for non existent claim")
# print("\tskip activate support for non existent claim")
continue
self.staged_activated_support[activated.claim_hash].append(amount)
self.pending_activated[activated.name][activated.claim_hash].append((activated_txo, amount))
print(f"\tactivate {'support' if txo_type == ACTIVATED_SUPPORT_TXO_TYPE else 'claim'} "
f"lbry://{activated.name}#{activated.claim_hash.hex()} @ {activated_txo.height}")
# print(f"\tactivate {'support' if txo_type == ACTIVATED_SUPPORT_TXO_TYPE else 'claim'} "
# f"{activated.claim_hash.hex()} @ {activated_txo.height}")
if reactivate:
ops.extend(
StagedActivation(
@ -1041,8 +1041,8 @@ class BlockProcessor:
activate_key, self.db.get_claim_txo_amount(candidate_claim_hash)
))
need_reactivate_if_takes_over[(need_takeover, candidate_claim_hash)] = activate_key
print(f"\tcandidate to takeover abandoned controlling claim for lbry://{need_takeover} - "
f"{activate_key.tx_num}:{activate_key.position} {activate_key.is_claim}")
# print(f"\tcandidate to takeover abandoned controlling claim for "
# f"{activate_key.tx_num}:{activate_key.position} {activate_key.is_claim}")
if not has_candidate:
# remove name takeover entry, the name is now unclaimed
controlling = get_controlling(need_takeover)
@ -1117,8 +1117,8 @@ class BlockProcessor:
if winning_claim_hash != winning_including_future_activations and \
future_winning_amount > amounts[winning_claim_hash]:
print(f"\ttakeover of {name} by {winning_claim_hash.hex()} triggered early activation and "
f"takeover by {winning_including_future_activations.hex()} at {height}")
# print(f"\ttakeover by {winning_claim_hash.hex()} triggered early activation and "
# f"takeover by {winning_including_future_activations.hex()} at {height}")
# handle a pending activated claim jumping the takeover delay when another name takes over
if winning_including_future_activations not in self.pending_claim_txos:
claim = self.db.get_claim_txo(winning_including_future_activations)
@ -1169,7 +1169,7 @@ class BlockProcessor:
elif not controlling or (winning_claim_hash != controlling.claim_hash and
name in names_with_abandoned_controlling_claims) or \
((winning_claim_hash != controlling.claim_hash) and (amounts[winning_claim_hash] > amounts[controlling.claim_hash])):
print(f"\ttakeover {name} by {winning_claim_hash.hex()} at {height}")
# print(f"\ttakeover by {winning_claim_hash.hex()} at {height}")
if (name, winning_claim_hash) in need_reactivate_if_takes_over:
previous_pending_activate = need_reactivate_if_takes_over[(name, winning_claim_hash)]
amount = self.db.get_claim_txo_amount(
@ -1196,10 +1196,10 @@ class BlockProcessor:
)
ops.extend(get_takeover_name_ops(name, winning_claim_hash, height, controlling))
elif winning_claim_hash == controlling.claim_hash:
print("\tstill winning")
# print("\tstill winning")
pass
else:
print("\tno takeover")
# print("\tno takeover")
pass
# handle remaining takeovers from abandoned supports
@ -1216,7 +1216,7 @@ class BlockProcessor:
amounts[controlling.claim_hash] = self._get_pending_effective_amount(name, controlling.claim_hash)
winning = max(amounts, key=lambda x: amounts[x])
if (controlling and winning != controlling.claim_hash) or (not controlling and winning):
print(f"\ttakeover from abandoned support {controlling.claim_hash.hex()} -> {winning.hex()}")
# print(f"\ttakeover from abandoned support {controlling.claim_hash.hex()} -> {winning.hex()}")
ops.extend(get_takeover_name_ops(name, winning, height, controlling))
# gather cumulative removed/touched sets to update the search index
@ -1227,7 +1227,7 @@ class BlockProcessor:
).difference(self.removed_claims_to_send_es)
)
# for use the cumulative changes to now update bid ordered resolve
# use the cumulative changes to update bid ordered resolve
for removed in self.removed_claims_to_send_es:
removed_claim = self.db.get_claim_txo(removed)
if not removed_claim:
@ -1258,7 +1258,7 @@ class BlockProcessor:
def advance_block(self, block):
height = self.height + 1
print("advance ", height)
# print("advance ", height)
txs: List[Tuple[Tx, bytes]] = block.transactions
block_hash = self.coin.header_hash(block.header)

View file

@ -65,8 +65,6 @@ class BaseResolveTestCase(CommandTestCase):
async def assertMatchClaimsForName(self, name):
expected = json.loads(await self.blockchain._cli_cmnd('getclaimsforname', name))
print(len(expected['claims']), 'from lbrycrd for ', name)
db = self.conductor.spv_node.server.bp.db
def check_supports(claim_id, lbrycrd_supports):