Skip to content

Commit

Permalink
Refactor target_peers inf. magic value to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Nov 20, 2020
1 parent 7f338c9 commit c16d7b1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/tribler-core/tribler_core/modules/ipv8_module_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
from ipv8.peer import Peer


INFINITE = -1
"""
The amount of target_peers for a walk_strategy definition to never stop.
"""


class IPv8CommunityLauncher(CommunityLauncher):

def get_my_peer(self, ipv8, session):
Expand All @@ -20,9 +26,9 @@ def should_launch(self, session):

@precondition('session.config.get_discovery_community_enabled()')
@overlay('ipv8.peerdiscovery.community', 'DiscoveryCommunity')
@walk_strategy('ipv8.peerdiscovery.churn', 'RandomChurn', target_peers=-1)
@walk_strategy('ipv8.peerdiscovery.churn', 'RandomChurn', target_peers=INFINITE)
@walk_strategy('ipv8.peerdiscovery.discovery', 'RandomWalk')
@walk_strategy('ipv8.peerdiscovery.community', 'PeriodicSimilarity', target_peers=-1)
@walk_strategy('ipv8.peerdiscovery.community', 'PeriodicSimilarity', target_peers=INFINITE)
class IPv8DiscoveryCommunityLauncher(IPv8CommunityLauncher):

def finalize(self, ipv8, session, community):
Expand All @@ -48,7 +54,7 @@ class BandwidthTestnetCommunityLauncher(TestnetMixIn, BandwidthCommunityLauncher
@precondition('session.config.get_dht_enabled()')
@set_in_session('dht_community')
@overlay('ipv8.dht.discovery', 'DHTDiscoveryCommunity')
@walk_strategy('ipv8.dht.churn', 'PingChurn', target_peers=-1)
@walk_strategy('ipv8.dht.churn', 'PingChurn', target_peers=INFINITE)
@walk_strategy('ipv8.peerdiscovery.discovery', 'RandomWalk')
class DHTCommunityLauncher(IPv8CommunityLauncher):
pass
Expand All @@ -65,7 +71,7 @@ class DHTCommunityLauncher(IPv8CommunityLauncher):
random_slots='session.config.get_tunnel_community_random_slots()',
tribler_session='session')
@walk_strategy('ipv8.peerdiscovery.discovery', 'RandomWalk')
@walk_strategy('tribler_core.modules.tunnel.community.discovery', 'GoldenRatioStrategy', target_peers=-1)
@walk_strategy('tribler_core.modules.tunnel.community.discovery', 'GoldenRatioStrategy', target_peers=INFINITE)
class TriblerTunnelCommunityLauncher(IPv8CommunityLauncher):

def get_kwargs(self, session):
Expand Down Expand Up @@ -104,7 +110,7 @@ class PopularityCommunityLauncher(IPv8CommunityLauncher):
@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=-1)
@walk_strategy('tribler_core.modules.metadata_store.community.sync_strategy', 'SyncChannels', target_peers=INFINITE)
class GigaChannelCommunityLauncher(IPv8CommunityLauncher):
pass

Expand All @@ -123,7 +129,7 @@ class GigaChannelTestnetCommunityLauncher(TestnetMixIn, GigaChannelCommunityLaun
@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=-1)
@walk_strategy('tribler_core.modules.metadata_store.community.sync_strategy', 'RemovePeers', target_peers=INFINITE)
class RemoteQueryCommunityLauncher(IPv8CommunityLauncher):
pass

Expand Down

0 comments on commit c16d7b1

Please sign in to comment.