Skip to content

Commit

Permalink
verifier: small clean-up
Browse files Browse the repository at this point in the history
this code runs in the interface's group, so it's confusing to call the network's methods
  • Loading branch information
SomberNight committed Apr 4, 2022
1 parent 184e122 commit 250795f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions electrum/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from .transaction import Transaction
from .blockchain import hash_header
from .interface import GracefulDisconnect
from .network import UntrustedServerReturnedError
from . import constants

if TYPE_CHECKING:
Expand Down Expand Up @@ -82,13 +81,13 @@ async def _request_proofs(self):
if tx_hash in self.requested_merkle or tx_hash in self.merkle_roots:
continue
# or before headers are available
if tx_height <= 0 or tx_height > local_height:
if not (0 < tx_height <= local_height):
continue
# if it's in the checkpoint region, we still might not have the header
header = self.blockchain.read_header(tx_height)
if header is None:
if tx_height < constants.net.max_checkpoint():
await self.taskgroup.spawn(self.network.request_chunk(tx_height, None, can_return_early=True))
await self.taskgroup.spawn(self.interface.request_chunk(tx_height, None, can_return_early=True))
continue
# request now
self.logger.info(f'requested merkle {tx_hash}')
Expand All @@ -98,10 +97,8 @@ async def _request_proofs(self):
async def _request_and_verify_single_proof(self, tx_hash, tx_height):
try:
async with self._network_request_semaphore:
merkle = await self.network.get_merkle_for_transaction(tx_hash, tx_height)
except UntrustedServerReturnedError as e:
if not isinstance(e.original_exception, aiorpcx.jsonrpc.RPCError):
raise
merkle = await self.interface.get_merkle_for_transaction(tx_hash, tx_height)
except aiorpcx.jsonrpc.RPCError:
self.logger.info(f'tx {tx_hash} not at height {tx_height}')
self.wallet.remove_unverified_tx(tx_hash, tx_height)
self.requested_merkle.discard(tx_hash)
Expand Down

0 comments on commit 250795f

Please sign in to comment.