Skip to content

Commit

Permalink
Fixed statistics not being enabled for any overlays (#7554)
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink authored Jul 21, 2023
1 parent ff7639b commit 737a7e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/tribler/core/components/ipv8/ipv8_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ async def run(self):
key_component = await self.require_component(KeyComponent)
self.peer = Peer(key_component.primary_key)

if config.ipv8.statistics and not config.gui_test_mode:
# Enable gathering IPv8 statistics
for overlay in ipv8.overlays:
ipv8.endpoint.enable_community_statistics(overlay.get_prefix(), True)

if config.ipv8.walk_scaling_enabled and not config.gui_test_mode:
from tribler.core.components.ipv8.ipv8_health_monitor import IPv8Monitor
IPv8Monitor(ipv8,
Expand Down Expand Up @@ -102,6 +97,9 @@ def initialise_community_by_default(self, community, default_random_walk_max_pee
random_walk_max_peers = max(0, random_walk_max_peers)
self.ipv8.add_strategy(community, RandomWalk(community), random_walk_max_peers)

if self.session.config.ipv8.statistics and not self.session.config.gui_test_mode:
self.ipv8.endpoint.enable_community_statistics(community.get_prefix(), True)

async def unload_community(self, community):
await self.ipv8.unload_overlay(community)

Expand Down
10 changes: 10 additions & 0 deletions src/tribler/core/components/ipv8/tests/test_ipv8_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ async def test_ipv8_component_discovery_community_enabled(tribler_config):
async with Session(tribler_config, [KeyComponent(), Ipv8Component()]) as session:
comp = session.get_instance(Ipv8Component)
assert comp._peer_discovery_community


async def test_ipv8_component_statistics_enabled(tribler_config):
tribler_config.ipv8.enabled = True
tribler_config.ipv8.statistics = True
tribler_config.gui_test_mode = False
tribler_config.dht.enabled = True
async with Session(tribler_config, [KeyComponent(), Ipv8Component()]) as session:
comp = session.get_instance(Ipv8Component)
assert comp.dht_discovery_community.get_prefix() in comp.ipv8.endpoint.statistics

0 comments on commit 737a7e7

Please sign in to comment.