Skip to content

Commit b801ff8

Browse files
2colorachingbrain
andauthored
docs: update delegated routing (#2784)
- Update the docs with up-to-date information about delegated routing including the example. - Fix some broken links and examples --------- Co-authored-by: Daniel N <[email protected]> Co-authored-by: Alex Potsides <[email protected]>
1 parent 0f728b5 commit b801ff8

File tree

1 file changed

+21
-40
lines changed

1 file changed

+21
-40
lines changed

doc/CONFIGURATION.md

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
- [Customizing Peer Discovery](#customizing-peer-discovery)
1818
- [Customizing Pubsub](#customizing-pubsub)
1919
- [Customizing DHT](#customizing-dht)
20-
- [Setup with Content and Peer Routing](#setup-with-content-and-peer-routing)
20+
- [Setup with Delegated Content and Peer Routing](#setup-with-delegated-content-and-peer-routing)
2121
- [Setup with Relay](#setup-with-relay)
2222
- [Setup with Automatic Reservations](#setup-with-automatic-reservations)
2323
- [Setup with Preconfigured Reservations](#setup-with-preconfigured-reservations)
@@ -145,14 +145,15 @@ If you want to know more about libp2p peer discovery, you should read the follow
145145
Some available content routing modules are:
146146

147147
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p/tree/main/packages/kad-dht)
148+
- [@helia/delegated-routing-v1-http-api-client](https://github.com/ipfs/helia-delegated-routing-v1-http-api)
148149
- [@libp2p/delegated-content-routing](https://github.com/libp2p/js-libp2p-delegated-content-routing)
149-
- [@libp2p/ipni-content-routing](https://github.com/libp2p/js-ipni-content-routing)
150150

151-
If none of the available content routing protocols fulfil your needs, you can create a libp2p compatible one. A libp2p content routing protocol just needs to be compliant with the [Content Routing Interface](https://github.com/libp2p/js-libp2p/tree/main/packages/interface/content-routing).
151+
> [!NOTE]
152+
> The `@helia/delegated-routing-v1-http-api-client` module is a client for the [IPFS Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/). It is not a libp2p module, but it can be used in conjunction with libp2p to provide content and peer routing functionality.
153+
> For most purposes, `@helia/delegated-routing-v1-http-api-client` should be favoured over `@libp2p/delegated-content-routing` for delegated routing, as it is more broadly adopted by the ecosystem and doesn't rely on Kubo specific APIs.
152154
153-
If you want to know more about libp2p content routing, you should read the following content:
155+
If none of the available content routing protocols fulfil your needs, you can create a libp2p compatible one. A libp2p content routing protocol just needs to be compliant with the [Content Routing Interface](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/src/content-routing/index.ts).
154156

155-
- https://docs.libp2p.io/concepts/content-routing
156157

157158
### Peer Routing
158159

@@ -161,13 +162,14 @@ If you want to know more about libp2p content routing, you should read the follo
161162
Some available peer routing modules are:
162163

163164
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p/tree/main/packages/kad-dht)
165+
- [@helia/delegated-routing-v1-http-api-client](https://github.com/ipfs/helia-delegated-routing-v1-http-api)
164166
- [@libp2p/delegated-peer-routing](https://github.com/libp2p/js-libp2p-delegated-peer-routing)
167+
If none of the available peer routing protocols fulfills your needs, you can create a libp2p compatible one. A libp2p peer routing protocol just needs to be compliant with the [Peer Routing Interface](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/src/peer-routing/index.ts).
165168

166-
If none of the available peer routing protocols fulfills your needs, you can create a libp2p compatible one. A libp2p peer routing protocol just needs to be compliant with the [Peer Routing Interface](https://github.com/libp2p/js-libp2p/tree/main/packages/interface/peer-routing). **(WIP: This module is not yet implemented)**
169+
> [!NOTE]
170+
> The `@helia/delegated-routing-v1-http-api-client` module is a client for the [IPFS Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/). It is not a libp2p module, but it can be used in conjunction with libp2p to provide content and peer routing functionality.
171+
> For most purposes, `@helia/delegated-routing-v1-http-api-client` should be favoured over `@libp2p/delegated-content-routing` for delegated routing, as it is more broadly adopted by the ecosystem and doesn't rely on Kubo specific APIs.
167172
168-
If you want to know more about libp2p peer routing, you should read the following content:
169-
170-
- https://docs.libp2p.io/concepts/peer-routing
171173

172174
### DHT
173175

@@ -219,7 +221,7 @@ const modules = {
219221
Moreover, the majority of the modules can be customized via option parameters. This way, it is also possible to provide this options through a `config` object. This config object should have the property name of each building block to configure, the same way as the modules specification.
220222

221223
Besides the `modules` and `config`, libp2p allows other internal options and configurations:
222-
- `datastore`: an instance of [ipfs/interface-datastore](https://github.com/ipfs/js-ipfs-interfaces/tree/master/packages/interface-datastore) modules.
224+
- `datastore`: an instance of [ipfs/interface-datastore](https://github.com/ipfs/js-stores/tree/main/packages/interface-datastore) modules.
223225
- This is used in modules such as the DHT. If it is not provided, `js-libp2p` will use an in memory datastore.
224226
- `peerId`: the identity of the node, an instance of [libp2p/js-peer-id](https://github.com/libp2p/js-peer-id).
225227
- This is particularly useful if you want to reuse the same `peer-id`, as well as for modules like `libp2p-delegated-content-routing`, which need a `peer-id` in their instantiation.
@@ -314,7 +316,8 @@ Potential methods for discovering peers include:
314316
- [Distributed hash tables](#dht)
315317
- [Local network broadcasts](https://docs.libp2p.io/concepts/discovery-routing/mdns/)
316318
- [Centralized trackers or rendezvous points](https://docs.libp2p.io/concepts/discovery-routing/rendezvous/)
317-
- [Lists of bootstrap peers](https://github.com/libp2p/js-libp2p-bootstrap)
319+
- [Lists of bootstrap peers](https://github.com/ipfs/helia/blob/main/packages/helia/src/utils/bootstrappers.ts)
320+
318321
```js
319322
import { createLibp2p } from 'libp2p'
320323
import { tcp } from '@libp2p/tcp'
@@ -379,32 +382,14 @@ const node = await createLibp2p({
379382
})
380383
```
381384

382-
#### Setup with Content and Peer Routing
385+
#### Setup with Delegated Content and Peer Routing
383386

384387
```js
385388
import { createLibp2p } from 'libp2p'
386389
import { tcp } from '@libp2p/tcp'
387390
import { yamux } from '@chainsafe/libp2p-yamux'
388391
import { noise } from '@chainsafe/libp2p-noise'
389-
import { create as ipfsHttpClient } from 'ipfs-http-client'
390-
import { DelegatedPeerRouting } from '@libp2p/delegated-peer-routing'
391-
import { DelegatedContentRouting} from '@libp2p/delegated-content-routing'
392-
393-
// create a peerId
394-
const peerId = await PeerId.create()
395-
396-
const delegatedPeerRouting = new DelegatedPeerRouting(ipfsHttpClient.create({
397-
host: 'node0.delegate.ipfs.io', // In production you should setup your own delegates
398-
protocol: 'https',
399-
port: 443
400-
}))
401-
402-
const delegatedContentRouting = new DelegatedContentRouting(peerId, ipfsHttpClient.create({
403-
host: 'node0.delegate.ipfs.io', // In production you should setup your own delegates
404-
protocol: 'https',
405-
port: 443
406-
}))
407-
392+
import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
408393
const node = await createLibp2p({
409394
transports: [
410395
tcp()
@@ -415,13 +400,9 @@ const node = await createLibp2p({
415400
connectionEncrypters: [
416401
noise()
417402
],
418-
contentRouting: [
419-
delegatedContentRouting
420-
],
421-
peerRouting: [
422-
delegatedPeerRouting
423-
],
424-
peerId
403+
services: {
404+
delegatedRouting: () => createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev'),
405+
}
425406
})
426407
```
427408

@@ -999,8 +980,8 @@ protocols: [
999980

1000981
As libp2p is designed to be a modular networking library, its usage will vary based on individual project needs. We've included links to some existing project configurations for your reference, in case you wish to replicate their configuration:
1001982

1002-
- [libp2p-ipfs-nodejs](https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-core-config/src/libp2p.js) - libp2p configuration used by js-ipfs when running in Node.js
1003-
- [libp2p-ipfs-browser](https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-core-config/src/libp2p.browser.js) - libp2p configuration used by js-ipfs when running in a Browser (that supports WebRTC)
983+
- [libp2p-Helia-nodejs](https://github.com/ipfs/helia/blob/main/packages/helia/src/utils/libp2p-defaults.ts) - libp2p configuration used by Helia when running in Node.js
984+
- [libp2p-Helia-browser](https://github.com/ipfs/helia/blob/main/packages/helia/src/utils/libp2p-defaults.browser.ts) - libp2p configuration used by Helia when running in a Browser
1004985

1005986
If you have developed a project using `js-libp2p`, please consider submitting your configuration to this list so that it can be found easily by other users.
1006987

0 commit comments

Comments
 (0)