From 299a299412b0c3c15966996f3466db3960e324e7 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 9 Jan 2014 04:39:50 +0400 Subject: Use K parameter in routing table lookups --- src/Network/BitTorrent/DHT/Routing.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Network/BitTorrent/DHT/Routing.hs b/src/Network/BitTorrent/DHT/Routing.hs index 22076a39..293d58ab 100644 --- a/src/Network/BitTorrent/DHT/Routing.hs +++ b/src/Network/BitTorrent/DHT/Routing.hs @@ -386,7 +386,8 @@ defaultK = 8 -- | Get a list of /K/ closest nodes using XOR metric. Used in -- 'find_node' queries. kclosest :: Eq ip => K -> NodeId -> Table ip -> [NodeInfo ip] -kclosest k nid = L.map key . PSQ.toList . fromMaybe PSQ.empty +kclosest k nid = L.take k . rank nid + . L.map key . PSQ.toList . fromMaybe PSQ.empty . lookupBucket nid coerceId :: (Serialize a, Serialize b) => a -> b -- cgit v1.2.3