add hub_timeout and propagate it to network code
This commit is contained in:
parent
99f56f5d22
commit
e7fdf2aeb3
5 changed files with 16 additions and 2 deletions
|
@ -544,6 +544,7 @@ class Config(CLIConfig):
|
|||
# protocol timeouts
|
||||
download_timeout = Float("Cumulative timeout for a stream to begin downloading before giving up", 30.0)
|
||||
blob_download_timeout = Float("Timeout to download a blob from a peer", 30.0)
|
||||
hub_timeout = Float("Timeout when making a hub request", 30.0)
|
||||
peer_connect_timeout = Float("Timeout to establish a TCP connection to a peer", 3.0)
|
||||
node_rpc_timeout = Float("Timeout when making a DHT request", constants.RPC_TIMEOUT)
|
||||
|
||||
|
|
|
@ -182,6 +182,7 @@ class WalletManager:
|
|||
|
||||
ledger_config = {
|
||||
'auto_connect': True,
|
||||
'hub_timeout': config.hub_timeout,
|
||||
'default_servers': config.lbryum_servers,
|
||||
'data_path': config.wallet_dir,
|
||||
'tx_cache_size': config.transaction_cache_size
|
||||
|
@ -226,6 +227,7 @@ class WalletManager:
|
|||
self.ledger.config = {
|
||||
'auto_connect': True,
|
||||
'default_servers': self.config.lbryum_servers,
|
||||
'hub_timeout': self.config.hub_timeout,
|
||||
'data_path': self.config.wallet_dir,
|
||||
}
|
||||
await self.ledger.stop()
|
||||
|
|
|
@ -263,7 +263,7 @@ class Network:
|
|||
async def connect_to_fastest(self) -> Optional[ClientSession]:
|
||||
fastest_spvs = await self.get_n_fastest_spvs()
|
||||
for (host, port) in fastest_spvs:
|
||||
client = ClientSession(network=self, server=(host, port))
|
||||
client = ClientSession(network=self, server=(host, port), timeout=self.config['hub_timeout'])
|
||||
try:
|
||||
await client.create_connection()
|
||||
log.warning("Connected to spv server %s:%i", host, port)
|
||||
|
|
|
@ -131,7 +131,8 @@ class WalletNode:
|
|||
self.ledger_class.get_id(): {
|
||||
'api_port': self.port,
|
||||
'default_servers': [(spv_node.hostname, spv_node.port)],
|
||||
'data_path': self.data_path
|
||||
'data_path': self.data_path,
|
||||
'hub_timeout': 30,
|
||||
}
|
||||
},
|
||||
'wallets': [wallet_file_name]
|
||||
|
|
|
@ -9,6 +9,7 @@ from lbry.wallet.orchstr8.node import SPVNode
|
|||
from lbry.wallet.rpc import RPCSession
|
||||
from lbry.wallet.server.udp import StatusServer
|
||||
from lbry.testcase import IntegrationTestCase, AsyncioTestCase
|
||||
from lbry.conf import Config
|
||||
|
||||
|
||||
class NetworkTests(IntegrationTestCase):
|
||||
|
@ -138,6 +139,15 @@ class ReconnectTests(IntegrationTestCase):
|
|||
await self.ledger.network.on_connected.first
|
||||
self.assertTrue(self.ledger.network.is_connected)
|
||||
|
||||
async def test_timeout_propagated_from_config(self):
|
||||
conf = Config()
|
||||
self.assertEqual(self.ledger.network.client.timeout, 30)
|
||||
conf.hub_timeout = 123.0
|
||||
conf.lbryum_servers = self.ledger.config['default_servers']
|
||||
self.manager.config = conf
|
||||
await self.manager.reset()
|
||||
self.assertEqual(self.ledger.network.client.timeout, 123)
|
||||
|
||||
# async def test_online_but_still_unavailable(self):
|
||||
# # Edge case. See issue #2445 for context
|
||||
# self.assertIsNotNone(self.ledger.network.session_pool.fastest_session)
|
||||
|
|
Loading…
Reference in a new issue