@@ -264,11 +264,15 @@ discarded.
264
264
265
265
#### Termination
266
266
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.
272
276
273
277
#### Concurrency
274
278
@@ -310,30 +314,71 @@ private addresses.
310
314
311
315
` GetClosestPeers ` also makes use of the ` FIND_NODE ` RPC, but allows the sender
312
316
to 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 ) .
314
319
315
- ` GetClosestPeers ` is used for Content Routing.
320
+ ` GetClosestPeers ` is used for the purpose of Content Routing.
316
321
317
322
### Signed Peer Records
318
323
319
324
` FIXME ` : Signed Peer Records are not yet implemented in the IPFS Kademlia DHT.
320
325
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.
322
340
323
341
### Content Kademlia Identifier
324
342
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.
326
346
327
- ### Lookup Termination and Resiliency
347
+ Example:
328
348
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
+ ```
330
354
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.
332
376
333
377
#### Provide Validity
334
378
335
379
Provide 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.
337
382
338
383
#### Provider Record Republish Interval
339
384
@@ -350,8 +395,24 @@ content provider alongside the provide record, avoiding an additional DHT walk
350
395
for the Client
351
396
([ rationale] ( https://github.com/probe-lab/network-measurements/blob/master/results/rfm17.1-sharing-prs-with-multiaddresses.md ) ).
352
397
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
+
353
412
### IPNS
354
413
414
+ ### Resiliency
415
+
355
416
### Validators
356
417
357
418
## RPC Messages
0 commit comments