pymdht
pymdht copied to clipboard
Pymdht.get_peers returns unrelated peers
Pymdht.get_peers
returns too many peers for a non-existent info hash. This observation should be reproduced by the following code:
import sys
import logging
sys.path.append('')
from pymdht.core.pymdht import Pymdht as DHT
from pymdht.core.node import Node
from pymdht.plugins import lookup_a4
from pymdht.plugins import routing_nice_rtt
from pymdht.core import exp_plugin_template
from pymdht.core.identifier import Id
my_node = Node(['127.0.0.1', 12345])
conf_path = ''
private_dht_name = None
debug_level = logging.INFO
auto_bootstrap = True
bootstrap_mode = False
dht = DHT(my_node, conf_path, routing_nice_rtt, lookup_a4, exp_plugin_template,
private_dht_name, debug_level, auto_bootstrap, bootstrap_mode)
info_hash = '1234567890123456789012345678901234567890'
peers = set()
def f(lookup_id, peer_list, node):
if peer_list is None:
print(peers)
print(len(peers))
else:
for i in peer_list:
peers.add(i)
dht.get_peers(None, Id(info_hash), f)
I get over 600 peers in the test, which is obviously too much for that info hash. version 12.11.0 release