@@ -331,23 +331,22 @@ and make error handling more complex.
331331
332332### Server behavior
333333
334- Upon receiving a lookup request for a Kademlia Identifier, a DHT Server MUST
335- return the Peer ID and multiaddresses of the ` k ` closest nodes to the requested
336- Kademlia Identifier that are stored in its Routing Table. DHT Servers SHOULD
337- NOT return any information about unresponsive nodes.
334+ Upon receiving a lookup request for a Kademlia Identifier ` kid ` , a DHT Server
335+ MUST return the Peer ID and multiaddresses of the ` k ` closest DHT Servers to
336+ ` kid ` that are stored in its Routing Table. It SHOULD NOT include itself, nor
337+ the requester in the response. If itself or the requester's Peer ID are among
338+ the ` k ` closest DHT Servers, it SHOULD return the next closest nodes instead,
339+ to return a total of ` k ` DHT Servers. DHT Servers SHOULD NOT return any
340+ information about unresponsive nodes.
338341
339342In public DHT swarms, DHT Servers MUST filter out private and loopback
340- multiaddresses, and MUST NOT include peers whose only addresses are private or
341- loopback.
343+ multiaddresses, and MUST NOT include DHT Servers whose only addresses are
344+ private or loopback.
342345
343- DHT Servers SHOULD NOT return their own Peer ID in responses to ` FIND_NODE `
344- queries. However, they MUST include information about the requester, if and
345- only if the requester is a DHT Server in its routing table and it is among the
346- ` k ` closest nodes to the target key.
347-
348- A DHT Server SHOULD always return information about its known ` k ` closest
349- peers, provided its routing table contains at least ` k ` peers, even if those
350- peers are not closer to the target key than itself.
346+ A DHT Server SHOULD always return information about the ` k ` closest DHT Servers
347+ to ` kid ` (excluding self and the requester), provided its routing table
348+ contains enough DHT Servers, even if these DHT Servers are not closer to ` kid `
349+ than self or the requester.
351350
352351### Client behavior
353352
@@ -408,7 +407,7 @@ established a connection to the target Peer ID.
408407
409408#### Discovering non-DHT Servers
410409
411- DHT clients that want to remain routable must ensure their multiaddresses are
410+ DHT clients that want to remain routable MUST ensure their multiaddresses are
412411stored in the peerstore of the DHT Servers closest to them in XOR distance.
413412Since peerstore entries expire over time, DHT Clients SHOULD periodically
414413reconnect to their closest DHT servers to prevent their information from being
@@ -417,7 +416,9 @@ removed. Implementations SHOULD perform this reconnection every 10 minutes.
417416When receiving a ` FIND_NODE ` request for a given Peer ID, DHT Servers MUST
418417always respond with the information of that Peer ID, if it is included in their
419418peerstore, even if the target node isn't a DHT Server or only advertises
420- private addresses.
419+ private addresses. Moreover, if the target Peer ID is self, or the requester's
420+ Peer ID, the corresponding peer information should be included in addition to
421+ the ` k ` closest DHT Servers.
421422
422423### ` GetClosestPeers `
423424
0 commit comments