forked from LBRYCommunity/lbry-sdk
debugging
This commit is contained in:
parent
5f3850bfa2
commit
6330424bcd
1 changed files with 20 additions and 20 deletions
|
@ -449,7 +449,7 @@ class BlockProcessor:
|
||||||
self.removed_claims_to_send_es.clear()
|
self.removed_claims_to_send_es.clear()
|
||||||
self.pending_reposted.clear()
|
self.pending_reposted.clear()
|
||||||
self.pending_channel_counts.clear()
|
self.pending_channel_counts.clear()
|
||||||
# print("******************\n")
|
print("******************\n")
|
||||||
except:
|
except:
|
||||||
self.logger.exception("advance blocks failed")
|
self.logger.exception("advance blocks failed")
|
||||||
raise
|
raise
|
||||||
|
@ -602,10 +602,10 @@ class BlockProcessor:
|
||||||
claim_name = ''.join(chr(c) for c in txo.script.values['claim_name'])
|
claim_name = ''.join(chr(c) for c in txo.script.values['claim_name'])
|
||||||
if txo.script.is_claim_name:
|
if txo.script.is_claim_name:
|
||||||
claim_hash = hash160(tx_hash + pack('>I', nout))[::-1]
|
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 lbry://{claim_name}#{claim_hash.hex()} ({tx_num} {txo.amount})")
|
||||||
else:
|
else:
|
||||||
claim_hash = txo.claim_hash[::-1]
|
claim_hash = txo.claim_hash[::-1]
|
||||||
# print(f"\tupdate lbry://{claim_name}#{claim_hash.hex()} ({tx_num} {txo.amount})")
|
print(f"\tupdate lbry://{claim_name}#{claim_hash.hex()} ({tx_num} {txo.amount})")
|
||||||
|
|
||||||
signing_channel_hash = None
|
signing_channel_hash = None
|
||||||
channel_signature_is_valid = False
|
channel_signature_is_valid = False
|
||||||
|
@ -663,7 +663,7 @@ class BlockProcessor:
|
||||||
root_tx_num, root_idx = tx_num, nout
|
root_tx_num, root_idx = tx_num, nout
|
||||||
else: # it's a claim update
|
else: # it's a claim update
|
||||||
if claim_hash not in spent_claims:
|
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 []
|
return []
|
||||||
(prev_tx_num, prev_idx, _) = spent_claims.pop(claim_hash)
|
(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 lbry://{claim_name}#{claim_hash.hex()} {tx_hash[::-1].hex()} {txo.amount}")
|
||||||
|
@ -694,7 +694,7 @@ class BlockProcessor:
|
||||||
supported_claim_hash = txo.claim_hash[::-1]
|
supported_claim_hash = txo.claim_hash[::-1]
|
||||||
self.pending_supports[supported_claim_hash].append((tx_num, nout))
|
self.pending_supports[supported_claim_hash].append((tx_num, nout))
|
||||||
self.pending_support_txos[(tx_num, nout)] = supported_claim_hash, txo.amount
|
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(
|
return StagedClaimtrieSupport(
|
||||||
supported_claim_hash, tx_num, nout, txo.amount
|
supported_claim_hash, tx_num, nout, txo.amount
|
||||||
).get_add_support_utxo_ops()
|
).get_add_support_utxo_ops()
|
||||||
|
@ -803,7 +803,7 @@ class BlockProcessor:
|
||||||
ops = []
|
ops = []
|
||||||
|
|
||||||
for abandoned_claim_hash, (tx_num, nout, name) in spent_claims.items():
|
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 lbry://{name}#{abandoned_claim_hash.hex()} {tx_num} {nout}")
|
||||||
ops.extend(self._abandon_claim(abandoned_claim_hash, tx_num, nout, name))
|
ops.extend(self._abandon_claim(abandoned_claim_hash, tx_num, nout, name))
|
||||||
return ops
|
return ops
|
||||||
|
|
||||||
|
@ -915,7 +915,7 @@ class BlockProcessor:
|
||||||
controlling = get_controlling(staged.name)
|
controlling = get_controlling(staged.name)
|
||||||
if controlling and controlling.claim_hash == claim_hash:
|
if controlling and controlling.claim_hash == claim_hash:
|
||||||
names_with_abandoned_controlling_claims.append(staged.name)
|
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)
|
activation = self.db.get_activation(staged.tx_num, staged.position)
|
||||||
if activation > 0: # db returns -1 for non-existent txos
|
if activation > 0: # db returns -1 for non-existent txos
|
||||||
# removed queued future activation from the db
|
# removed queued future activation from the db
|
||||||
|
@ -972,7 +972,7 @@ class BlockProcessor:
|
||||||
for activated_txo in activated_txos:
|
for activated_txo in activated_txos:
|
||||||
if activated_txo.is_support and (activated_txo.tx_num, activated_txo.position) in \
|
if activated_txo.is_support and (activated_txo.tx_num, activated_txo.position) in \
|
||||||
self.pending_removed_support[activated.name][activated.claim_hash]:
|
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
|
continue
|
||||||
if activated_txo.is_claim:
|
if activated_txo.is_claim:
|
||||||
txo_type = ACTIVATED_CLAIM_TXO_TYPE
|
txo_type = ACTIVATED_CLAIM_TXO_TYPE
|
||||||
|
@ -995,8 +995,8 @@ class BlockProcessor:
|
||||||
)
|
)
|
||||||
self.staged_activated_support[activated.claim_hash].append(amount)
|
self.staged_activated_support[activated.claim_hash].append(amount)
|
||||||
self.pending_activated[activated.name][activated.claim_hash].append((activated_txo, 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'} "
|
print(f"\tactivate {'support' if txo_type == ACTIVATED_SUPPORT_TXO_TYPE else 'claim'} "
|
||||||
# f"lbry://{activated.name}#{activated.claim_hash.hex()} @ {activated_txo.height}")
|
f"lbry://{activated.name}#{activated.claim_hash.hex()} @ {activated_txo.height}")
|
||||||
if reactivate:
|
if reactivate:
|
||||||
ops.extend(
|
ops.extend(
|
||||||
StagedActivation(
|
StagedActivation(
|
||||||
|
@ -1025,8 +1025,8 @@ class BlockProcessor:
|
||||||
activate_key, self.db.get_claim_txo_amount(candidate_claim_hash, tx_num, nout)
|
activate_key, self.db.get_claim_txo_amount(candidate_claim_hash, tx_num, nout)
|
||||||
))
|
))
|
||||||
need_reactivate_if_takes_over[(need_takeover, candidate_claim_hash)] = activate_key
|
need_reactivate_if_takes_over[(need_takeover, candidate_claim_hash)] = activate_key
|
||||||
# print(f"\tcandidate to takeover abandoned controlling claim for lbry://{need_takeover} - "
|
print(f"\tcandidate to takeover abandoned controlling claim for lbry://{need_takeover} - "
|
||||||
# f"{activate_key.tx_num}:{activate_key.position} {activate_key.is_claim}")
|
f"{activate_key.tx_num}:{activate_key.position} {activate_key.is_claim}")
|
||||||
if not has_candidate:
|
if not has_candidate:
|
||||||
# remove name takeover entry, the name is now unclaimed
|
# remove name takeover entry, the name is now unclaimed
|
||||||
controlling = get_controlling(need_takeover)
|
controlling = get_controlling(need_takeover)
|
||||||
|
@ -1084,9 +1084,9 @@ class BlockProcessor:
|
||||||
winning_including_future_activations = max(
|
winning_including_future_activations = max(
|
||||||
amounts_with_future_activations, key=lambda x: amounts_with_future_activations[x]
|
amounts_with_future_activations, key=lambda x: amounts_with_future_activations[x]
|
||||||
)
|
)
|
||||||
if winning_claim_hash != winning_including_future_activations:
|
if winning_claim_hash != winning_including_future_activations: # TODO: and amount is higher and claim exists
|
||||||
# print(f"\ttakeover of {name} by {winning_claim_hash.hex()} triggered early activation and "
|
print(f"\ttakeover of {name} by {winning_claim_hash.hex()} triggered early activation and "
|
||||||
# f"takeover by {winning_including_future_activations.hex()} at {height}")
|
f"takeover by {winning_including_future_activations.hex()} at {height}")
|
||||||
# handle a pending activated claim jumping the takeover delay when another name takes over
|
# 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:
|
if winning_including_future_activations not in self.pending_claim_txos:
|
||||||
claim = self.db.get_claim_txo(winning_including_future_activations)
|
claim = self.db.get_claim_txo(winning_including_future_activations)
|
||||||
|
@ -1137,7 +1137,7 @@ class BlockProcessor:
|
||||||
elif not controlling or (winning_claim_hash != controlling.claim_hash and
|
elif not controlling or (winning_claim_hash != controlling.claim_hash and
|
||||||
name in names_with_abandoned_controlling_claims) or \
|
name in names_with_abandoned_controlling_claims) or \
|
||||||
((winning_claim_hash != controlling.claim_hash) and (amounts[winning_claim_hash] > amounts[controlling.claim_hash])):
|
((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 {name} by {winning_claim_hash.hex()} at {height}")
|
||||||
if (name, winning_claim_hash) in need_reactivate_if_takes_over:
|
if (name, winning_claim_hash) in need_reactivate_if_takes_over:
|
||||||
previous_pending_activate = need_reactivate_if_takes_over[(name, winning_claim_hash)]
|
previous_pending_activate = need_reactivate_if_takes_over[(name, winning_claim_hash)]
|
||||||
amount = self.db.get_claim_txo_amount(
|
amount = self.db.get_claim_txo_amount(
|
||||||
|
@ -1164,10 +1164,10 @@ class BlockProcessor:
|
||||||
)
|
)
|
||||||
ops.extend(get_takeover_name_ops(name, winning_claim_hash, height, controlling))
|
ops.extend(get_takeover_name_ops(name, winning_claim_hash, height, controlling))
|
||||||
elif winning_claim_hash == controlling.claim_hash:
|
elif winning_claim_hash == controlling.claim_hash:
|
||||||
# print("\tstill winning")
|
print("\tstill winning")
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# print("\tno takeover")
|
print("\tno takeover")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# handle remaining takeovers from abandoned supports
|
# handle remaining takeovers from abandoned supports
|
||||||
|
@ -1184,7 +1184,7 @@ class BlockProcessor:
|
||||||
amounts[controlling.claim_hash] = self._get_pending_effective_amount(name, controlling.claim_hash)
|
amounts[controlling.claim_hash] = self._get_pending_effective_amount(name, controlling.claim_hash)
|
||||||
winning = max(amounts, key=lambda x: amounts[x])
|
winning = max(amounts, key=lambda x: amounts[x])
|
||||||
if (controlling and winning != controlling.claim_hash) or (not controlling and winning):
|
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))
|
ops.extend(get_takeover_name_ops(name, winning, height, controlling))
|
||||||
|
|
||||||
# gather cumulative removed/touched sets to update the search index
|
# gather cumulative removed/touched sets to update the search index
|
||||||
|
@ -1228,7 +1228,7 @@ class BlockProcessor:
|
||||||
|
|
||||||
def advance_block(self, block):
|
def advance_block(self, block):
|
||||||
height = self.height + 1
|
height = self.height + 1
|
||||||
# print("advance ", height)
|
print("advance ", height)
|
||||||
txs: List[Tuple[Tx, bytes]] = block.transactions
|
txs: List[Tuple[Tx, bytes]] = block.transactions
|
||||||
block_hash = self.coin.header_hash(block.header)
|
block_hash = self.coin.header_hash(block.header)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue