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: 78f0fbc25578472be9d4380568175ba4474cadf1
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: e69d01365f73c620dd7a3bb720225b33e82ad3c3
Choose a head ref
Loading
Showing with 333 additions and 250 deletions.
  1. +18 −5 .aegir.js
  2. +2 −1 .gitignore
  3. +100 −0 CHANGELOG.md
  4. +24 −14 README.md
  5. +25 −14 package.json
  6. +72 −73 src/index.js
  7. +92 −143 test/index.spec.js
23 changes: 18 additions & 5 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
'use strict'

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

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

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

await server.start()
},
post: () => server.stop()
}
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -61,4 +61,5 @@ typings/
.env

yarn.lock
package-lock.json
package-lock.json
dist/
100 changes: 100 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,103 @@
<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)


### Bug Fixes

* limit concurrent HTTP requests ([#16](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/16)) ([55d6108](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/55d6108)), closes [#12](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/12) [/github.com/libp2p/js-libp2p-delegated-content-routing/issues/12#issuecomment-514591525](https://github.com//github.com/libp2p/js-libp2p-delegated-content-routing/issues/12/issues/issuecomment-514591525)



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


### Features

* refactor to use async/await ([#7](https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/7)) ([0e2d91f](https://github.com/libp2p/js-libp2p-delegated-content-routing/commit/0e2d91f))


### BREAKING CHANGES

* API refactored to use async/await



<a name="0.2.3"></a>
## [0.2.3](https://github.com/libp2p/js-libp2p-delegated-content-routing/compare/v0.2.2...v0.2.3) (2019-07-11)

38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# js-libp2p-delegated-content-routing

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)
[![](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-delegated-content-routing.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-delegated-content-routing)
[![](https://img.shields.io/travis/libp2p/js-libp2p-delegated-content-routing.svg?style=flat-square)](https://travis-ci.com/libp2p/js-libp2p-delegated-content-routing)
[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-delegated-content-routing.svg?style=flat-square)](https://david-dm.org/libp2p/js-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.

## Lead Maintainer

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

## Requirements

`libp2p-delegated-content-routing` leverages the `ipfs-http-client` library and requires it as a peer dependency, as such, both must be installed in order for this module to work properly.

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

## Example

```js
@@ -18,22 +36,14 @@ const routing = new DelegatedContentRouing(peerId, {
port: 443,
host: 'ipfs.io'
})
const cid = new CID('QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv')

routing.findProviders(key, (err, peerInfos) => {
if (err) {
return console.error(err)
}

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

routing.provide(key, (err) => {
if (err) {
return console.error(err)
}

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

## License
39 changes: 25 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libp2p-delegated-content-routing",
"version": "0.2.3",
"version": "0.5.0",
"description": "Leverage other peers in the libp2p network to perform Content Routing calls.",
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
"main": "src/index.js",
@@ -10,31 +10,42 @@
"scripts": {
"lint": "aegir lint",
"build": "aegir build",
"test": "aegir test -f test/**/*.js",
"test:node": "aegir test --target node -f test/**/*.js",
"test": "aegir test",
"test:node": "aegir test --target node",
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"coverage": "aegir coverage"
},
"devDependencies": {
"aegir": "^19.0.5",
"aegir": "^21.8.1",
"chai": "^4.2.0",
"cids": "^0.7.1",
"go-ipfs-dep": "^0.4.21",
"ipfsd-ctl": "^0.43.0"
"cids": "^0.8.0",
"go-ipfs-dep": "0.4.23-3",
"ipfs-http-client": "^44.0.0",
"ipfs-utils": "^2.2.0",
"ipfsd-ctl": "^4.0.1",
"it-drain": "^1.0.0",
"it-last": "^1.0.1",
"peer-id": "^0.13.11"
},
"peerDependencies": {
"ipfs-http-client": "^44.0.0"
},
"dependencies": {
"async": "^2.6.2",
"ipfs-http-client": "^33.0.2",
"multiaddr": "^6.1.0",
"peer-id": "^0.12.2",
"peer-info": "^0.15.1"
"debug": "^4.1.1",
"it-all": "^1.0.0",
"multiaddr": "^7.4.3",
"p-defer": "^3.0.0",
"p-queue": "^6.2.1"
},
"contributors": [
"Jacob Heun <jacobheun@gmail.com>",
"Vasco Santos <vasco.santos@moxy.studio>",
"Alan Shaw <alan.shaw@protocol.ai>",
"David Dias <daviddias.p@gmail.com>",
"Alex Potsides <alex@achingbrain.net>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Jacob Heun <jacobheun@gmail.com>"
"David Dias <daviddias.p@gmail.com>",
"Marcin Rataj <lidel@lidel.org>"
]
}
Loading