Leverage other peers in the libp2p network to perform Content Routing calls.
$ npm i @libp2p/delegated-content-routing
Loading this module through a script tag will make it's exports available as Libp2pDelegatedContentRouting
in the global namespace.
<script src="https://unpkg.com/@libp2p/delegated-content-routing/dist/index.min.js"></script>
Leverage other peers in the network to perform Content Routing calls.
Requires access to /api/v0/dht/findprovs
and /api/v0/refs
HTTP API endpoints of the delegate node.
@libp2p/delegated-content-routing
leverages the kubo-rpc-client
library and requires an instance of it as a constructor argument.
npm install kubo-rpc-client @libp2p/delegated-content-routing
import { createLibp2p } from 'libp2p'
import { delegatedContentRouting } from '@libp2p/delegated-content-routing'
import { create as createIpfsHttpClient } from 'kubo-rpc-client'
// default is to use ipfs.io
const client = createIpfsHttpClient({
// use default api settings
protocol: 'https',
port: 443,
host: 'node0.delegate.ipfs.io'
})
const node = await createLibp2p({
peerRouting: [
delegatedContentRouting(client)
]
//.. other config
})
await node.start()
for await (const provider of node.contentRouting.findProviders('cid')) {
console.log('provider', provider)
}
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.