From 250795f137281b8d2c8d29081949ee781a1c0b2a Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 4 Apr 2022 20:51:18 +0200 Subject: [PATCH] verifier: small clean-up this code runs in the interface's group, so it's confusing to call the network's methods --- electrum/verifier.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/electrum/verifier.py b/electrum/verifier.py index 0f96ef4d40f..dec907a779b 100644 --- a/electrum/verifier.py +++ b/electrum/verifier.py @@ -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: @@ -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}') @@ -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)