mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
wallet: don't try to get_input_tx from network when offline
related: https://github.com/spesmilo/electrum/issues/6648#issuecomment-708499893 Trying to fetch the prev tx from the network is a blocking operation with a 10 sec timeout - we should not hang for 10 seconds if there is no network connection.
This commit is contained in:
parent
292016d283
commit
bde415cae7
2 changed files with 7 additions and 1 deletions
|
@ -328,6 +328,7 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
|
||||||
self.debug = False
|
self.debug = False
|
||||||
|
|
||||||
self._set_status('disconnected')
|
self._set_status('disconnected')
|
||||||
|
self._has_ever_managed_to_connect_to_server = False
|
||||||
|
|
||||||
# lightning network
|
# lightning network
|
||||||
self.channel_db = None # type: Optional[ChannelDB]
|
self.channel_db = None # type: Optional[ChannelDB]
|
||||||
|
@ -339,6 +340,10 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
|
||||||
self.local_watchtower.start_network(self)
|
self.local_watchtower.start_network(self)
|
||||||
asyncio.ensure_future(self.local_watchtower.start_watching())
|
asyncio.ensure_future(self.local_watchtower.start_watching())
|
||||||
|
|
||||||
|
def has_internet_connection(self) -> bool:
|
||||||
|
"""Our guess whether the device has Internet-connectivity."""
|
||||||
|
return self._has_ever_managed_to_connect_to_server
|
||||||
|
|
||||||
def is_lightning_running(self):
|
def is_lightning_running(self):
|
||||||
return self.channel_db is not None
|
return self.channel_db is not None
|
||||||
|
|
||||||
|
@ -768,6 +773,7 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
|
||||||
if server == self.default_server:
|
if server == self.default_server:
|
||||||
await self.switch_to_interface(server)
|
await self.switch_to_interface(server)
|
||||||
|
|
||||||
|
self._has_ever_managed_to_connect_to_server = True
|
||||||
self._add_recent_server(server)
|
self._add_recent_server(server)
|
||||||
util.trigger_callback('network_updated')
|
util.trigger_callback('network_updated')
|
||||||
|
|
||||||
|
|
|
@ -1613,7 +1613,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
# will likely be. If co-signing a transaction it may not have
|
# will likely be. If co-signing a transaction it may not have
|
||||||
# all the input txs, in which case we ask the network.
|
# all the input txs, in which case we ask the network.
|
||||||
tx = self.db.get_transaction(tx_hash)
|
tx = self.db.get_transaction(tx_hash)
|
||||||
if not tx and self.network:
|
if not tx and self.network and self.network.has_internet_connection():
|
||||||
try:
|
try:
|
||||||
raw_tx = self.network.run_from_another_thread(
|
raw_tx = self.network.run_from_another_thread(
|
||||||
self.network.get_transaction(tx_hash, timeout=10))
|
self.network.get_transaction(tx_hash, timeout=10))
|
||||||
|
|
Loading…
Add table
Reference in a new issue