Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: libp2p/js-libp2p-delegated-content-routing
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ac371f1cdceba09ee9a136963b2b4e3da396c582
Choose a base ref
...
head repository: libp2p/js-libp2p-delegated-content-routing
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d433941f991eed908f6aecc74bc902d632f22a53
Choose a head ref
Loading
Showing with 458 additions and 177 deletions.
  1. +17 −8 .aegir.js
  2. +50 −0 .github/workflows/main.yml
  3. +0 −42 .travis.yml
  4. +195 −0 CHANGELOG.md
  5. +16 −5 README.md
  6. +25 −17 package.json
  7. +75 −40 src/index.js
  8. +80 −65 test/index.spec.js
25 changes: 17 additions & 8 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
'use strict'

const createServer = require('ipfsd-ctl').createServer

const server = createServer()
const { createServer } = require('ipfsd-ctl')
let server

module.exports = {
hooks: {
browser: {
pre: () => server.start(),
post: () => server.stop()
}
test: {
before: async () => {
server = createServer({
host: '127.0.0.1',
port: 57483
}, {
type: 'go',
ipfsHttpModule: require('ipfs-http-client'),
ipfsBin: require('go-ipfs').path(),
test: true
})

await server.start()
},
after: () => server.stop()
}
}
50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- run: npx aegir dep-check
- run: npx aegir build
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [14, 15]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
# modules with pre-built binaries may not have deployed versions for bleeding-edge node so this lets us fall back to building from source
- run: npm install node-pre-gyp -g
- run: npm install
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir test -t browser -t webworker --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

195 changes: 195 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,198 @@
# [0.11.0](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.10.0...v0.11.0) (2021-07-07)


### chore

* update to new multiformats ([#52](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/52)) ([f34c7d2](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/f34c7d29e1c2016242a13e23799e428d2a751e6f))


### BREAKING CHANGES

* uses the CID class from the new multiformats module



# [0.10.0](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.9.0...v0.10.0) (2021-04-09)



# [0.9.0](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.8.1...v0.9.0) (2021-01-20)


### Features

* allow providing non-dag-pb nodes ([#47](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/47)) ([28d3a45](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/28d3a456bc8aaaa359586a056b5366d89fc5e738))



## [0.8.2](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.8.1...v0.8.2) (2020-11-30)



## [0.8.1](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.4.1...v0.8.1) (2020-11-27)


### Bug Fixes

* accept http client instance ([#43](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/43)) ([003888a](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/003888a8eab1c8bd5aaed7adec58e8722ec4b2ff))
* catch find providers error ([#37](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/37)) ([9cc766c](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/9cc766cb6ee9525f46843f2cbb30802f7da0f039))
* replace node buffers with uint8arrays ([#42](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/42)) ([381815e](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/381815e0cd10cba6ee4d21ba46f8ddda9df4da83))


### chore

* make ipfs-http-client a peer dependency ([#39](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/39)) ([0c0f304](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/0c0f304217eb40fe96278b6f7bfafb6a77900a83))
* remove peer-info from api ([#34](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/34)) ([2c97221](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/2c972211b002ecc9f3a9cd2fa0fba04b08b854f8))


### BREAKING CHANGES

* - An instance of ipfs http client is now a required argument

* chore: update node versions

* chore: update readme

* chore: restore peer deps
* - all useage of node Buffers has been replaced with Uint8Arrays
- all deps now use Uint8Arrays instead of node Buffers

* test: fix provide test

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
* The ipfs-http-client must now be installed
as a peer dependency. It is no longer included as a dependency
of this module.

The reason the http-client should be a peerDependency and
not a dependency is that its API requires knowledge of the
http-client (we pass in the api endpoint details).
* findProviders returns id and addrs properties instead of peer-info instance

* chore: address review



# [0.8.0](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.7.0...v0.8.0) (2020-10-21)



<a name="0.7.0"></a>
# [0.7.0](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.6.0...v0.7.0) (2020-08-26)


### Bug Fixes

* accept http client instance ([#43](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/43)) ([003888a](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/003888a))


### BREAKING CHANGES

* - An instance of ipfs http client is now a required argument

* chore: update node versions

* chore: update readme

* chore: restore peer deps



<a name="0.6.0"></a>
# [0.6.0](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.5.0...v0.6.0) (2020-08-12)


### Bug Fixes

* replace node buffers with uint8arrays ([#42](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/42)) ([381815e](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/381815e))


### BREAKING CHANGES

* - all useage of node Buffers has been replaced with Uint8Arrays
- all deps now use Uint8Arrays instead of node Buffers

* test: fix provide test

Co-authored-by: Jacob Heun <jacobheun@gmail.com>



<a name="0.5.0"></a>
# [0.5.0](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.4.5...v0.5.0) (2020-04-23)


### Chores

* make ipfs-http-client a peer dependency ([#39](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/39)) ([0c0f304](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/0c0f304))
* remove peer-info from api ([#34](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/34)) ([2c97221](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/2c97221))


### BREAKING CHANGES

* The ipfs-http-client must now be installed
as a peer dependency. It is no longer included as a dependency
of this module.

The reason the http-client should be a peerDependency and
not a dependency is that its API requires knowledge of the
http-client (we pass in the api endpoint details).
* findProviders returns id and addrs properties instead of peer-info instance

* chore: address review



<a name="0.4.5"></a>
## [0.4.5](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.4.4...v0.4.5) (2020-04-16)


### Bug Fixes

* catch find providers error ([#37](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/37)) ([9cc766c](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/9cc766c))



<a name="0.4.4"></a>
## [0.4.4](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.4.3...v0.4.4) (2020-04-09)



<a name="0.4.3"></a>
## [0.4.3](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.4.2...v0.4.3) (2020-02-04)



<a name="0.4.2"></a>
## [0.4.2](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.4.1...v0.4.2) (2019-12-20)



<a name="0.4.1"></a>
## [0.4.1](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.4.0...v0.4.1) (2019-12-01)


### Bug Fixes

* async it refs ([#19](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/19)) ([b2690c7](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/b2690c7))



<a name="0.4.0"></a>
# [0.4.0](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.3.1...v0.4.0) (2019-11-29)


### Chores

* rename timeout option ([#18](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/18)) ([22ff40c](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/22ff40c))


### BREAKING CHANGES

* maxTimeout option renamed to timeout



<a name="0.3.1"></a>
## [0.3.1](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.3.0...v0.3.1) (2019-07-24)

21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -10,26 +10,37 @@

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.

## Lead Maintainer

[Jacob Heun](https://github.com/jacobheun)

## Requirements

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

```sh
npm install ipfs-http-client libp2p-delegated-content-routing
```

## Example

```js
const DelegatedContentRouting = require('libp2p-delegated-content-routing')
const ipfsHttpClient = require('ipfs-http-client')

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

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

await routing.provide(cid)
Loading