Skip to content

Commit

Permalink
Fix DHTHealthManager
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Jun 11, 2020
1 parent 8ffb40a commit c5de5d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/tribler-core/tribler_core/modules/dht_health_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math
from asyncio import Future

from ipv8.dht.routing import distance, id_to_binary_string
from ipv8.dht.routing import distance
from ipv8.taskmanager import TaskManager

import libtorrent as lt
Expand Down Expand Up @@ -127,9 +127,7 @@ def received_bloomfilters(self, node_id, bf_seeds=bytearray(256), bf_peers=bytea
# We do not know to which infohash the received get_peers response belongs so we have to manually go through
# the infohashes and find the infohash that is the closest to the node id that sent us the message.
for infohash in self.lookup_futures:
infohash_bin = id_to_binary_string(infohash)
node_id_bin = id_to_binary_string(node_id)
ih_distance = distance(infohash_bin, node_id_bin)
ih_distance = distance(infohash, node_id)
if ih_distance < min_distance or min_distance == -1:
min_distance = ih_distance
closest_infohash = infohash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def test_receive_bloomfilters(self):
"""
Test whether the right operations happen when receiving a bloom filter
"""
infohash = 'a' * 20
infohash = b'a' * 20
self.dht_health_manager.received_bloomfilters(infohash) # It should not do anything
self.assertFalse(self.dht_health_manager.bf_seeders)
self.assertFalse(self.dht_health_manager.bf_peers)
Expand Down

0 comments on commit c5de5d7

Please sign in to comment.