avoid trapping errors on client

This commit is contained in:
Victor Shyba 2019-11-17 22:29:22 -03:00 committed by Lex Berezhny
parent 719d18c670
commit f0390786d6
4 changed files with 4 additions and 13 deletions

View file

@ -176,10 +176,10 @@ class LbryWalletManager(BaseWalletManager):
if not tx:
try:
raw = await self.ledger.network.get_transaction(txid)
if not raw:
return {'success': False, 'code': 404, 'message': 'transaction not found'}
height = await self.ledger.network.get_transaction_height(txid)
except CodeMessageError as e:
if 'No such mempool or blockchain transaction.' in e.message:
return {'success': False, 'code': 404, 'message': 'transaction not found'}
return {'success': False, 'code': e.code, 'message': e.message}
tx = self.ledger.transaction_class(unhexlify(raw))
await self.ledger.maybe_verify_transaction(tx, height)

View file

@ -175,5 +175,3 @@ class BasicTransactionTests(IntegrationTestCase):
self.assertTrue(await self.ledger.update_history(address, remote_status))
self.assertEqual(21, len((await self.ledger.get_local_status_and_history(address))[1]))
self.assertEqual(0, len(self.ledger._known_addresses_out_of_sync))
# should be another test, but it would be too much to setup just for that and it affects sync
self.assertIsNone(await self.ledger.network.retriable_call(self.ledger.network.get_transaction, '1'*64))

View file

@ -550,13 +550,9 @@ class BaseLedger(metaclass=LedgerRegistry):
if tx is None:
# fetch from network
_raw = await self.network.retriable_call(self.network.get_transaction, txid, remote_height)
if _raw:
tx = self.transaction_class(unhexlify(_raw))
cache_item.tx = tx # make sure it's saved before caching it
if tx is None:
raise ValueError(f'Transaction {txid} was not in database and not on network.')
await self.maybe_verify_transaction(tx, remote_height)
return tx

View file

@ -72,9 +72,6 @@ class ClientSession(BaseClientSession):
log.debug("got reply for %s from %s:%i", method, *self.server)
return reply
except (RPCError, ProtocolError) as e:
if str(e).find('.*no such .*transaction.*'):
# shouldn't the server return none instead?
return None
log.warning("Wallet server (%s:%i) returned an error. Code: %s Message: %s",
*self.server, *e.args)
raise e