remove dht requirement from stream manager component

This commit is contained in:
Jack Robison 2019-01-23 17:55:03 -05:00 committed by Lex Berezhny
parent 09afec1961
commit a3e64f9cef
2 changed files with 10 additions and 5 deletions

View file

@ -434,7 +434,7 @@ class HashAnnouncerComponent(Component):
class StreamManagerComponent(Component):
component_name = STREAM_MANAGER_COMPONENT
depends_on = [BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT]
depends_on = [BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT]
def __init__(self, component_manager):
super().__init__(component_manager)
@ -455,8 +455,10 @@ class StreamManagerComponent(Component):
blob_manager = self.component_manager.get_component(BLOB_COMPONENT)
storage = self.component_manager.get_component(DATABASE_COMPONENT)
wallet = self.component_manager.get_component(WALLET_COMPONENT)
try:
node = self.component_manager.get_component(DHT_COMPONENT)
except NameError:
node = None
log.info('Starting the file manager')
loop = asyncio.get_event_loop()
self.stream_manager = StreamManager(

View file

@ -44,8 +44,8 @@ comparison_operators = {
class StreamManager:
def __init__(self, loop: asyncio.BaseEventLoop, blob_manager: 'BlobFileManager', wallet: 'LbryWalletManager',
storage: 'SQLiteStorage', node: 'Node', peer_timeout: float, peer_connect_timeout: float,
fixed_peers: typing.Optional[typing.List['KademliaPeer']] = None):
storage: 'SQLiteStorage', node: typing.Optional['Node'], peer_timeout: float,
peer_connect_timeout: float, fixed_peers: typing.Optional[typing.List['KademliaPeer']] = None):
self.loop = loop
self.blob_manager = blob_manager
self.wallet = wallet
@ -79,6 +79,9 @@ class StreamManager:
self.streams.add(stream)
async def resume(self):
if not self.node:
log.warning("no DHT node given, cannot resume downloads")
return
await self.node.joined.wait()
resumed = 0
for stream in self.streams: