mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 15:31:31 +00:00
Reduce indentation level
This makes the method easier to read. Skip negative tx heights too. A transaction height can be negative too, see the wallet modules TX_HEIGHT_LOCAL and TX_HEIGHT_UNCONF_PARENT constants.
This commit is contained in:
parent
358722b9cc
commit
eb44ef327d
1 changed files with 18 additions and 16 deletions
|
@ -42,29 +42,31 @@ class SPV(ThreadJob):
|
||||||
interface = self.network.interface
|
interface = self.network.interface
|
||||||
if not interface:
|
if not interface:
|
||||||
return
|
return
|
||||||
|
|
||||||
blockchain = interface.blockchain
|
blockchain = interface.blockchain
|
||||||
if not blockchain:
|
if not blockchain:
|
||||||
return
|
return
|
||||||
lh = self.network.get_local_height()
|
|
||||||
|
local_height = self.network.get_local_height()
|
||||||
unverified = self.wallet.get_unverified_txs()
|
unverified = self.wallet.get_unverified_txs()
|
||||||
for tx_hash, tx_height in unverified.items():
|
for tx_hash, tx_height in unverified.items():
|
||||||
# do not request merkle branch before headers are available
|
# do not request merkle branch before headers are available
|
||||||
if (tx_height > 0) and (tx_height <= lh):
|
if tx_height <= 0 or tx_height > local_height:
|
||||||
header = blockchain.read_header(tx_height)
|
continue
|
||||||
if header is None:
|
|
||||||
index = tx_height // 2016
|
|
||||||
if index < len(blockchain.checkpoints):
|
|
||||||
self.network.request_chunk(interface, index)
|
|
||||||
else:
|
|
||||||
if (tx_hash not in self.requested_merkle
|
|
||||||
and tx_hash not in self.merkle_roots):
|
|
||||||
|
|
||||||
self.network.get_merkle_for_transaction(
|
header = blockchain.read_header(tx_height)
|
||||||
tx_hash,
|
if header is None:
|
||||||
tx_height,
|
index = tx_height // 2016
|
||||||
self.verify_merkle)
|
if index < len(blockchain.checkpoints):
|
||||||
self.print_error('requested merkle', tx_hash)
|
self.network.request_chunk(interface, index)
|
||||||
self.requested_merkle.add(tx_hash)
|
elif (tx_hash not in self.requested_merkle
|
||||||
|
and tx_hash not in self.merkle_roots):
|
||||||
|
self.network.get_merkle_for_transaction(
|
||||||
|
tx_hash,
|
||||||
|
tx_height,
|
||||||
|
self.verify_merkle)
|
||||||
|
self.print_error('requested merkle', tx_hash)
|
||||||
|
self.requested_merkle.add(tx_hash)
|
||||||
|
|
||||||
if self.network.blockchain() != self.blockchain:
|
if self.network.blockchain() != self.blockchain:
|
||||||
self.blockchain = self.network.blockchain()
|
self.blockchain = self.network.blockchain()
|
||||||
|
|
Loading…
Add table
Reference in a new issue