Skip to content

libp2p/js-libp2p-delegated-content-routing

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@libp2p/delegated-content-routing

libp2p.io IRC Discuss codecov CI

Leverage other peers in the libp2p network to perform Content Routing calls.

Table of contents

Install

$ npm i @libp2p/delegated-content-routing

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.

Requirements

@libp2p/delegated-content-routing leverages the ipfs-http-client library and requires an instance of it as a constructor argument.

npm install ipfs-http-client @libp2p/delegated-content-routing

Example

import { DelegatedContentRouting } from '@libp2p/delegated-content-routing'
import ipfsHttpClient from 'ipfs-http-client'

// default is to use ipfs.io
const routing = new DelegatedContentRouting(peerId, ipfsHttpClient.create({
  // use default api settings
  protocol: 'https',
  port: 443,
  host: 'node0.delegate.ipfs.io' // In production you should setup your own delegates
}))
const cid = new CID('QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv')

for await (const { id, multiaddrs } of routing.findProviders(cid)) {
  console.log('found peer', id, multiaddrs)
}

await routing.provide(cid)
console.log('providing %s', cid.toBaseEncodedString())

License

Licensed under either of

Contribution

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.

About

Leverage other peers in the network to perform Content Routing calls.

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published