fix empty buckets in routing_table_get

This commit is contained in:
Jack Robison 2018-11-13 09:36:52 -05:00
parent 9bb91b126d
commit b0718d295e
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -3114,6 +3114,7 @@ class Daemon(AuthJSONRPCServer):
result['buckets'] = {} result['buckets'] = {}
for i in range(len(self.dht_node._routingTable._buckets)): for i in range(len(self.dht_node._routingTable._buckets)):
result['buckets'][i] = []
for contact in self.dht_node._routingTable._buckets[i]._contacts: for contact in self.dht_node._routingTable._buckets[i]._contacts:
blobs = list(hosts.pop(contact)) if contact in hosts else [] blobs = list(hosts.pop(contact)) if contact in hosts else []
blob_hashes.update(blobs) blob_hashes.update(blobs)
@ -3123,7 +3124,7 @@ class Daemon(AuthJSONRPCServer):
"node_id": hexlify(contact.id).decode(), "node_id": hexlify(contact.id).decode(),
"blobs": blobs, "blobs": blobs,
} }
result['buckets'].setdefault(i, []).append(host) result['buckets'][i].append(host)
contact_set.add(hexlify(contact.id).decode()) contact_set.add(hexlify(contact.id).decode())
result['contacts'] = list(contact_set) result['contacts'] = list(contact_set)