-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce init and unload methods in ipv8_component
- Loading branch information
Showing
8 changed files
with
82 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,39 @@ | ||
from ipv8.peerdiscovery.discovery import RandomWalk | ||
from ipv8_service import IPv8 | ||
from tribler_core.components.base import Component | ||
from tribler_core.components.ipv8 import Ipv8Component | ||
from tribler_core.components.gigachannel.community.sync_strategy import RemovePeers | ||
from tribler_core.components.ipv8 import INFINITE, Ipv8Component | ||
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent | ||
from tribler_core.components.reporter import ReporterComponent | ||
from tribler_core.components.torrent_checker import TorrentCheckerComponent | ||
from tribler_core.components.gigachannel.community.sync_strategy import RemovePeers | ||
from tribler_core.modules.popularity.community import PopularityCommunity | ||
|
||
INFINITE = -1 | ||
|
||
|
||
class PopularityComponent(Component): | ||
community: PopularityCommunity | ||
_ipv8: IPv8 | ||
|
||
_ipv8_component: Ipv8Component | ||
|
||
async def run(self): | ||
await super().run() | ||
await self.get_component(ReporterComponent) | ||
|
||
config = self.session.config | ||
ipv8_component = await self.require_component(Ipv8Component) | ||
self._ipv8 = ipv8_component.ipv8 | ||
peer = ipv8_component.peer | ||
self._ipv8_component = await self.require_component(Ipv8Component) | ||
metadata_store_component = await self.require_component(MetadataStoreComponent) | ||
torrent_checker_component = await self.require_component(TorrentCheckerComponent) | ||
|
||
community = PopularityCommunity(peer, self._ipv8.endpoint, self._ipv8.network, | ||
config = self.session.config | ||
community = PopularityCommunity(self._ipv8_component.peer, | ||
self._ipv8_component.ipv8.endpoint, | ||
self._ipv8_component.ipv8.network, | ||
settings=config.popularity_community, | ||
rqc_settings=config.remote_query_community, | ||
metadata_store=metadata_store_component.mds, | ||
torrent_checker=torrent_checker_component.torrent_checker) | ||
self.community = community | ||
|
||
self._ipv8.add_strategy(community, RandomWalk(community), 30) | ||
self._ipv8.add_strategy(community, RemovePeers(community), INFINITE) | ||
|
||
community.bootstrappers.append(ipv8_component.make_bootstrapper()) | ||
self._ipv8_component.initialise_community_by_default(community) | ||
self._ipv8_component.ipv8.add_strategy(community, RemovePeers(community), INFINITE) | ||
|
||
async def shutdown(self): | ||
await self._ipv8.unload_overlay(self.community) | ||
await super().shutdown() | ||
await self._ipv8_component.unload_community(self.community) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters