Compare commits

..

11 Commits

Author SHA1 Message Date
7068aae527 chore: release version v0.4.0 2017-01-28 21:13:34 +00:00
d632451f92 chore: update contributors 2017-01-28 21:13:34 +00:00
8047e3fe64 feat: new discovery interface 2017-01-28 21:13:18 +00:00
35af31023c chore: update deps 2017-01-28 20:59:29 +00:00
078956b310 chore: release version v0.3.1 2016-12-01 12:17:33 +00:00
4f44158889 chore: update contributors 2016-12-01 12:17:32 +00:00
3a8d51c142 Merge pull request #48 from libp2p/feat/add-ping
feat: add ping to the mix
2016-12-01 12:17:10 +00:00
f8c09db20f feat: add ping to the mix 2016-12-01 11:53:27 +00:00
ee801c9be2 chore: release version v0.3.0 2016-11-28 10:40:29 +00:00
03349d7caf chore: update contributors 2016-11-28 10:40:29 +00:00
0c87dbc8f3 feat: export Node class at the top level 2016-11-28 10:38:40 +00:00
3 changed files with 53 additions and 14 deletions

View File

@ -41,7 +41,7 @@ To sum up, libp2p is a "network stack" -- a protocol suite -- that cleanly separ
With its modular nature, libp2p can be found being used in different projects with different sets of features, while perserving the same top level API. `js-libp2p` is only a skelleton and should not be installed directly, if you are looking for a prebundled libp2p stack, please check:
- [libp2p-ipfs](https://github.com/ipfs/js-libp2p-ipfs) - The libp2p build used by js-ipfs when run in Node.js
- [libp2p-ipfs-nodejs](https://github.com/ipfs/js-libp2p-ipfs-nodejs) - The libp2p build used by js-ipfs when run in Node.js
- [libp2p-ipfs-browser](https://github.com/ipfs/js-libp2p-ipfs-browser) - The libp2p build used by js-ipfs when run in a Browser (that supports WebRTC)
If you have developed a libp2p bundle, please consider submitting it to this list so that it can be found easily by the users of libp2p.
@ -81,7 +81,7 @@ Defined by [interface-libp2p](https://github.com/libp2p/interface-libp2p)
| Package | Version | Dependencies | DevDependencies |
|---------|---------|--------------|-----------------|
| **Bundles** |
| [`libp2p-ipfs`](//github.com/ipfs/js-libp2p-ipfs) | [![npm](https://img.shields.io/npm/v/libp2p-ipfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-libp2p-ipfs/releases) | [![Dependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs) | [![devDependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs/dev-status.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs?type=dev) |
| [`libp2p-ipfs-nodejs`](//github.com/ipfs/js-libp2p-ipfs-nodejs) | [![npm](https://img.shields.io/npm/v/libp2p-ipfs-nodejs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-libp2p-ipfs-nodejs/releases) | [![Dependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-nodejs.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-nodejs) | [![devDependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-nodejs/dev-status.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-nodejs?type=dev) |
| [`libp2p-ipfs-browser`](//github.com/ipfs/js-libp2p-ipfs-browser) | [![npm](https://img.shields.io/npm/v/libp2p-ipfs-browser.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-libp2p-ipfs-browser/releases) | [![Dependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-browser.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-browser) | [![devDependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-browser/dev-status.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-browser?type=dev) |
| **Transports** |
| [`libp2p-utp`](//github.com/libp2p/js-libp2p-utp) | [![npm](https://img.shields.io/npm/v/libp2p-utp.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-utp/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-utp.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-utp) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-utp/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-utp?type=dev) |

View File

@ -1,6 +1,6 @@
{
"name": "libp2p",
"version": "0.2.1",
"version": "0.4.0",
"description": "JavaScript Skeleton for libp2p bundles",
"main": "src/index.js",
"scripts": {
@ -35,16 +35,17 @@
"homepage": "https://github.com/diasdavid/js-libp2p",
"devDependencies": {
"chai": "^3.5.0",
"aegir": "^9.1.2",
"pre-commit": "^1.1.1"
"aegir": "^9.4.0",
"pre-commit": "^1.2.2"
},
"dependencies": {
"libp2p-swarm": "^0.26.3",
"mafmt": "^2.1.2",
"multiaddr": "^2.1.1",
"libp2p-ping": "^0.3.0",
"libp2p-swarm": "^0.26.13",
"mafmt": "^2.1.6",
"multiaddr": "^2.2.0",
"peer-book": "^0.3.0",
"peer-id": "^0.8.0",
"peer-info": "^0.8.1"
"peer-id": "^0.8.1",
"peer-info": "^0.8.2"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",

View File

@ -8,6 +8,7 @@ const multiaddr = require('multiaddr')
const mafmt = require('mafmt')
const EE = require('events').EventEmitter
const assert = require('assert')
const Ping = require('libp2p-ping')
exports = module.exports
@ -60,7 +61,7 @@ class Node {
}
// Attach discovery mechanisms
if (this.discovery) {
if (this.modules.discovery) {
let discoveries = this.modules.discovery
discoveries = Array.isArray(discoveries) ? discoveries : [discoveries]
discoveries.forEach((discovery) => {
@ -70,6 +71,9 @@ class Node {
})
}
// Mount default protocols
Ping.mount(this.swarm)
// Not fully implemented in js-libp2p yet
this.routing = undefined
this.records = undefined
@ -111,6 +115,13 @@ class Node {
}
this.isOnline = true
if (this.modules.discovery) {
this.modules.discovery.forEach((discovery) => {
setImmediate(() => discovery.start(() => {}))
})
}
callback()
})
}
@ -120,9 +131,38 @@ class Node {
*/
stop (callback) {
this.isOnline = false
if (this.modules.discovery) {
this.modules.discovery.forEach((discovery) => {
console.log(discovery)
setImmediate(() => discovery.stop(() => {}))
})
}
this.swarm.close(callback)
}
//
// Ping
//
// TODO
pingById (id, callback) {
assert(this.isOnline, OFFLINE_ERROR_MESSAGE)
callback(new Error('not implemented yet'))
}
// TODO
pingByMultiaddr (maddr, callback) {
assert(this.isOnline, OFFLINE_ERROR_MESSAGE)
callback(new Error('not implemented yet'))
}
pingByPeerInfo (peerInfo, callback) {
assert(this.isOnline, OFFLINE_ERROR_MESSAGE)
callback(null, new Ping(this.swarm, peerInfo))
}
//
// Dialing methods
//
@ -247,6 +287,4 @@ class Node {
}
}
module.exports = {
Node: Node
}
module.exports = Node