Skip to content

Commit

Permalink
Merge pull request #5736 from ichorid/feature/rqc_channel_preview
Browse files Browse the repository at this point in the history
Refactor RemoteQueryCommunity into the base class for GigaChannelCommunity and PopularityCommunity
  • Loading branch information
ichorid committed Nov 25, 2020
2 parents 2924131 + 5b6789a commit 2b9f9f5
Show file tree
Hide file tree
Showing 21 changed files with 608 additions and 1,021 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[tool.black]
line-length = 120
py27 = true
skip-string-normalization = true
include = '(src/tribler-gui|src/tribler-common|src/tribler-core/tribler_core/modules/metadata_store)/.*\.pyi?$'

Expand Down
30 changes: 4 additions & 26 deletions src/tribler-core/tribler_core/modules/ipv8_module_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from ipv8.loader import CommunityLauncher, after, kwargs, overlay, precondition, set_in_session, walk_strategy
from ipv8.peer import Peer


INFINITE = -1
"""
The amount of target_peers for a walk_strategy definition to never stop.
Expand Down Expand Up @@ -96,8 +95,7 @@ class TriblerTunnelTestnetCommunityLauncher(TestnetMixIn, TriblerTunnelCommunity
@precondition('session.config.get_popularity_community_enabled()')
@set_in_session('popularity_community')
@overlay('tribler_core.modules.popularity.popularity_community', 'PopularityCommunity')
@kwargs(metadata_store='session.mds', torrent_checker='session.torrent_checker',
notifier='session.notifier')
@kwargs(metadata_store='session.mds', torrent_checker='session.torrent_checker')
@walk_strategy('ipv8.peerdiscovery.discovery', 'RandomWalk')
class PopularityCommunityLauncher(IPv8CommunityLauncher):
pass
Expand All @@ -109,8 +107,9 @@ class PopularityCommunityLauncher(IPv8CommunityLauncher):
@set_in_session('gigachannel_community')
@overlay('tribler_core.modules.metadata_store.community.gigachannel_community', 'GigaChannelCommunity')
@kwargs(metadata_store='session.mds', notifier='session.notifier')
@walk_strategy('ipv8.peerdiscovery.discovery', 'RandomWalk')
@walk_strategy('tribler_core.modules.metadata_store.community.sync_strategy', 'SyncChannels', target_peers=INFINITE)
# GigaChannelCommunity remote search feature works better with higher amount of connected peers
@walk_strategy('ipv8.peerdiscovery.discovery', 'RandomWalk', target_peers=30)
@walk_strategy('tribler_core.modules.metadata_store.community.sync_strategy', 'RemovePeers', target_peers=INFINITE)
class GigaChannelCommunityLauncher(IPv8CommunityLauncher):
pass

Expand All @@ -122,25 +121,6 @@ class GigaChannelTestnetCommunityLauncher(TestnetMixIn, GigaChannelCommunityLaun
pass


@after('GigaChannelCommunity', 'GigaChannelTestnetCommunity')
@precondition('session.config.get_chant_enabled()')
@precondition('not session.config.get_chant_testnet()')
@set_in_session('remote_query_community')
@overlay('tribler_core.modules.metadata_store.community.remote_query_community', 'RemoteQueryCommunity')
@kwargs(metadata_store='session.mds', notifier='session.notifier')
@walk_strategy('ipv8.peerdiscovery.discovery', 'RandomWalk', target_peers=30)
@walk_strategy('tribler_core.modules.metadata_store.community.sync_strategy', 'RemovePeers', target_peers=INFINITE)
class RemoteQueryCommunityLauncher(IPv8CommunityLauncher):
pass


@precondition('session.config.get_chant_enabled()')
@precondition('session.config.get_chant_testnet()')
@overlay('tribler_core.modules.metadata_store.community.remote_query_community', 'RemoteQueryTestnetCommunity')
class RemoteQueryTestnetCommunityLauncher(TestnetMixIn, RemoteQueryCommunityLauncher):
pass


def get_hiddenimports():
"""
Return the set of all hidden imports defined by all CommunityLaunchers in this file.
Expand Down Expand Up @@ -171,5 +151,3 @@ def register_default_launchers(loader):
loader.set_launcher(PopularityCommunityLauncher())
loader.set_launcher(GigaChannelCommunityLauncher())
loader.set_launcher(GigaChannelTestnetCommunityLauncher())
loader.set_launcher(RemoteQueryCommunityLauncher())
loader.set_launcher(RemoteQueryTestnetCommunityLauncher())

0 comments on commit 2b9f9f5

Please sign in to comment.