fix routing_table_get
This commit is contained in:
parent
e85f8b245b
commit
95cb29d3c8
1 changed files with 13 additions and 12 deletions
|
@ -2845,14 +2845,14 @@ class Daemon(AuthJSONRPCServer):
|
||||||
|
|
||||||
contact = None
|
contact = None
|
||||||
if node_id and address and port:
|
if node_id and address and port:
|
||||||
contact = self.dht_node.contact_manager.get_contact(node_id.decode('hex'), address, int(port))
|
contact = self.dht_node.contact_manager.get_contact(unhexlify(node_id), address, int(port))
|
||||||
if not contact:
|
if not contact:
|
||||||
contact = self.dht_node.contact_manager.make_contact(
|
contact = self.dht_node.contact_manager.make_contact(
|
||||||
node_id.decode('hex'), address, int(port), self.dht_node._protocol
|
unhexlify(node_id), address, int(port), self.dht_node._protocol
|
||||||
)
|
)
|
||||||
if not contact:
|
if not contact:
|
||||||
try:
|
try:
|
||||||
contact = yield self.dht_node.findContact(node_id.decode('hex'))
|
contact = yield self.dht_node.findContact(unhexlify(node_id))
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
result = {'error': 'timeout finding peer'}
|
result = {'error': 'timeout finding peer'}
|
||||||
defer.returnValue(result)
|
defer.returnValue(result)
|
||||||
|
@ -2893,20 +2893,22 @@ class Daemon(AuthJSONRPCServer):
|
||||||
"node_id": (str) the local dht node id
|
"node_id": (str) the local dht node id
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
data_store = self.dht_node._dataStore._dict
|
data_store = self.dht_node._dataStore
|
||||||
datastore_len = len(data_store)
|
datastore_len = len(data_store)
|
||||||
hosts = {}
|
hosts = {}
|
||||||
|
|
||||||
if datastore_len:
|
if datastore_len:
|
||||||
for k, v in data_store.items():
|
for k, v in data_store.items():
|
||||||
for contact, value, lastPublished, originallyPublished, originalPublisherID in v:
|
for contact, value, lastPublished, originallyPublished, originalPublisherID in v:
|
||||||
blobs = blobs.get(contact, [])
|
if contact in hosts:
|
||||||
blobs.append(k.encode('hex'))
|
blobs = hosts[contact]
|
||||||
|
else:
|
||||||
|
blobs = []
|
||||||
|
blobs.append(hexlify(k))
|
||||||
hosts[contact] = blobs
|
hosts[contact] = blobs
|
||||||
|
|
||||||
contact_set = []
|
contact_set = set()
|
||||||
blob_hashes = []
|
blob_hashes = []
|
||||||
result['buckets'] = {}
|
result['buckets'] = {}
|
||||||
|
|
||||||
|
@ -2921,7 +2923,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
host = {
|
host = {
|
||||||
"address": contact.address,
|
"address": contact.address,
|
||||||
"port": contact.port,
|
"port": contact.port,
|
||||||
"node_id": contact.id.encode("hex"),
|
"node_id": hexlify(contact.id).decode(),
|
||||||
"blobs": blobs,
|
"blobs": blobs,
|
||||||
}
|
}
|
||||||
for blob_hash in blobs:
|
for blob_hash in blobs:
|
||||||
|
@ -2929,12 +2931,11 @@ class Daemon(AuthJSONRPCServer):
|
||||||
blob_hashes.append(blob_hash)
|
blob_hashes.append(blob_hash)
|
||||||
contacts.append(host)
|
contacts.append(host)
|
||||||
result['buckets'][i] = contacts
|
result['buckets'][i] = contacts
|
||||||
if contact.id.encode('hex') not in contact_set:
|
contact_set.add(hexlify(contact.id).decode())
|
||||||
contact_set.append(contact.id.encode("hex"))
|
|
||||||
|
|
||||||
result['contacts'] = contact_set
|
result['contacts'] = contact_set
|
||||||
result['blob_hashes'] = blob_hashes
|
result['blob_hashes'] = blob_hashes
|
||||||
result['node_id'] = self.dht_node.node_id.encode('hex')
|
result['node_id'] = hexlify(self.dht_node.node_id).decode()
|
||||||
return self._render_response(result)
|
return self._render_response(result)
|
||||||
|
|
||||||
# the single peer downloader needs wallet access
|
# the single peer downloader needs wallet access
|
||||||
|
|
Loading…
Reference in a new issue