@@ -264,11 +264,15 @@ discarded.
264264
265265#### Termination
266266
267- The lookup process continues until the ` k ` closest reachable peers to ` kid `
268- have been successfully queried. The process may also be terminated early if the
269- request-specific success criteria are met. Additionally, if every candidate
270- peer has been queried without discovering any new ones, the lookup will
271- terminate.
267+ The resilience parameter (` β ` ) defines the number of closest reachable peers
268+ that must be successfully queried before a lookup is considered complete. It is
269+ recommended to set ` β ` to ` 3 ` , ensuring that multiple nodes confirm the lookup
270+ result for increased reliability.
271+
272+ The lookup process continues until the ` β ` closest reachable peers to ` kid `
273+ have been queried. However, the process MAY terminate earlier if the
274+ request-specific success criteria are met. Additionally, if all candidate peers
275+ have been queried without discovering any new ones, the lookup MUST terminate.
272276
273277#### Concurrency
274278
@@ -310,30 +314,71 @@ private addresses.
310314
311315` GetClosestPeers ` also makes use of the ` FIND_NODE ` RPC, but allows the sender
312316to look for the ` k ` closest peers to any key. The ` key ` provided to ` FIND_NODE `
313- corresponds to the preimage of the Kademlia Identifier.
317+ corresponds to the preimage of the Kademlia Identifier, as described
318+ [ below] ( #content-kademlia-identifier ) .
314319
315- ` GetClosestPeers ` is used for Content Routing.
320+ ` GetClosestPeers ` is used for the purpose of Content Routing.
316321
317322### Signed Peer Records
318323
319324` FIXME ` : Signed Peer Records are not yet implemented in the IPFS Kademlia DHT.
320325
321- ## Content Routing
326+ ## Provider Record Routing
327+
328+ Provider Record Routing is the process of locating peers that provide a
329+ specific piece of content, identified by its CID. This is achieved by storing
330+ and retrieving Provider Records in the DHT.
331+
332+ ### Provider Records
333+
334+ A Provider Record is an entry stored in the DHT associating a CID with one or
335+ more Peer IDs providing the corresponding content. Instead of storing the
336+ content itself, the DHT stores provider records pointing to the peers hosting
337+ the content.
338+
339+ A Provider Record is identified by the multihash contained by the CID.
322340
323341### Content Kademlia Identifier
324342
325- sha256
343+ The Kademlia Identifier associated with a CID is derived from the multihash
344+ contained by the CID, by hashing it with the SHA256 hash function. The
345+ resulting 256-bit digest is used as the Kademlia Identifier for the content.
326346
327- ### Lookup Termination and Resiliency
347+ Example:
328348
329- Resiliency: Implementation specific. Recommendation is ` 3 `
349+ ``` sh
350+ CIDv1 (base32) : bafybeihfg3d7rdltd43u3tfvncx7n5loqofbsobojcadtmokrljfthuc7y
351+ CID contained hash (hex) : 1220e536c7f88d731f374dccb568aff6f56e838a19382e488039b1ca8ad2599e82fe
352+ Kademlia Identifier (hex): d623250f3f660ab4c3a53d3c97b3f6a0194c548053488d093520206248253bcb
353+ ```
330354
331- ### Provider Records
355+ ### Content Provider Advertisement
356+
357+ When a node wants to indicate that it provides the content associated with a
358+ given CID, it first finds the ` k ` closest DHT Servers to the Kademlia
359+ Identifier associated with the CID using [ ` GetClosestPeers ` ] ( #getclosestpeers ) .
360+ The ` key ` in the ` FIND_NODE ` payload is set to the multihash contained in the
361+ CID.
362+
363+ Once the ` k ` closest DHT Servers are found, the node sends each of them an
364+ ` ADD_PROVIDER ` RPC, using the same ` key ` and setting its own Peer ID as
365+ ` providerPeers ` .
366+
367+ The DHT Servers MUST make 2 checks before adding the provided ` record ` to their
368+ datastore:
369+ 1 . Verify that ` key ` is set, and doesn't exceed ` 80 ` bytes in size
370+ 2 . Discard ` providerPeers ` whose Peer ID is not matching the sender's Peer ID
371+
372+ Upon successful verification, the DHT Server stores the Provider Record in its
373+ datastore, and responds by echoing the request to confirm success. If
374+ verification fails, the server MUST close the stream without sending a
375+ response.
332376
333377#### Provide Validity
334378
335379Provide Validity defines the time-to-live (TTL) of a Provider Record on a DHT
336- Server. DHT Servers MUST implement a Provide Validity of ` 48h ` .
380+ Server. DHT Servers MUST implement a Provide Validity of ` 48h ` , and discard the
381+ record after expiration.
337382
338383#### Provider Record Republish Interval
339384
@@ -350,8 +395,24 @@ content provider alongside the provide record, avoiding an additional DHT walk
350395for the Client
351396([ rationale] ( https://github.com/probe-lab/network-measurements/blob/master/results/rfm17.1-sharing-prs-with-multiaddresses.md ) ).
352397
398+ ### Content Provider Lookup
399+
400+ To find providers for a given CID, a node initiates a lookup using the
401+ GET_PROVIDERS RPC. This process follows the same approach as a FIND_NODE
402+ lookup, but with one key difference: if a DHT server holds a matching provider
403+ record, it MUST include it in the response.
404+
405+ Clients MAY terminate the lookup early if they are satisfied with the returned
406+ providers. If a node does not find any provider records and is unable to
407+ discover closer DHT servers after querying the β closest reachable servers, the
408+ request is considered a failure.
409+
410+ ## DHT Record Storage
411+
353412### IPNS
354413
414+ ### Resiliency
415+
355416### Validators
356417
357418## RPC Messages
0 commit comments