forked from LBRYCommunity/lbry-sdk
use count parameter in findCloseNodes
This commit is contained in:
parent
7c50e26bd7
commit
ab956d4a8e
2 changed files with 5 additions and 4 deletions
|
@ -578,11 +578,12 @@ class Node(object):
|
|||
findValue = rpc != 'findNode'
|
||||
|
||||
if startupShortlist is None:
|
||||
shortlist = self._routingTable.findCloseNodes(key, constants.alpha)
|
||||
shortlist = self._routingTable.findCloseNodes(key, constants.k)
|
||||
if key != self.node_id:
|
||||
# Update the "last accessed" timestamp for the appropriate k-bucket
|
||||
self._routingTable.touchKBucket(key)
|
||||
if len(shortlist) == 0:
|
||||
log.warning("This node doesnt know any other nodes")
|
||||
# This node doesn't know of any other nodes
|
||||
fakeDf = defer.Deferred()
|
||||
fakeDf.callback([])
|
||||
|
|
|
@ -131,7 +131,7 @@ class TreeRoutingTable(object):
|
|||
canGoLower = bucketIndex - i >= 0
|
||||
canGoHigher = bucketIndex + i < len(self._buckets)
|
||||
# Fill up the node list to k nodes, starting with the closest neighbouring nodes known
|
||||
while len(closestNodes) < constants.k and (canGoLower or canGoHigher):
|
||||
while len(closestNodes) < min(count, constants.k) and (canGoLower or canGoHigher):
|
||||
# TODO: this may need to be optimized
|
||||
if canGoLower:
|
||||
closestNodes.extend(
|
||||
|
@ -140,8 +140,8 @@ class TreeRoutingTable(object):
|
|||
canGoLower = bucketIndex - (i + 1) >= 0
|
||||
if canGoHigher:
|
||||
closestNodes.extend(
|
||||
self._buckets[bucketIndex + i].getContacts(
|
||||
constants.k - len(closestNodes), _rpcNodeID))
|
||||
self._buckets[bucketIndex + i].getContacts(constants.k - len(closestNodes),
|
||||
_rpcNodeID))
|
||||
canGoHigher = bucketIndex + (i + 1) < len(self._buckets)
|
||||
i += 1
|
||||
return closestNodes
|
||||
|
|
Loading…
Add table
Reference in a new issue