Compare commits

...

19 Commits

Author SHA1 Message Date
109ee51d7b chore: release version v0.5.2 2017-02-09 10:18:38 -08:00
09182b43bf chore: update contributors 2017-02-09 10:18:38 -08:00
a130ab2dc1 chore: ^ to ~ 2017-02-09 10:16:51 -08:00
e24a1e43dc chore: release version v0.5.1 2017-01-28 21:20:21 +00:00
cb7d60ef65 chore: update contributors 2017-01-28 21:20:20 +00:00
a01b9479eb fix: remove unnecessary log 2017-01-28 21:20:16 +00:00
d01876a3d1 chore: release version v0.5.0 2017-01-28 21:14:26 +00:00
eb5eed8b21 chore: update contributors 2017-01-28 21:14:26 +00:00
3c58613b69 chore: release version v0.4.0 2017-01-28 21:14:04 +00:00
5dd5d37f6a feat: new discovery interface 2017-01-28 21:14:04 +00:00
6c3dd4b780 chore: update deps 2017-01-28 21:14:04 +00:00
06913271c7 docs(readme): fix typos 2017-01-16 12:01:09 +01:00
2cdd7033f0 add options 2016-12-11 12:03:21 -08:00
c2cf1da2ce Merge pull request #50 from libp2p/greenkeeper-aegir-9.2.1 2016-12-10 12:00:26 -08:00
8d0124ee5c chore(package): update aegir to version 9.2.1
https://greenkeeper.io/
2016-12-09 13:25:07 +01: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
3 changed files with 60 additions and 19 deletions

View File

@ -39,7 +39,7 @@ To sum up, libp2p is a "network stack" -- a protocol suite -- that cleanly separ
## Bundles
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:
With its modular nature, libp2p can be found being used in different projects with different sets of features, while preserving the same top level API. `js-libp2p` is only a skeleton and should not be installed directly, if you are looking for a prebundled libp2p stack, please check:
- [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)
@ -48,7 +48,7 @@ If you have developed a libp2p bundle, please consider submitting it to this lis
## Install
> Again, as noted above, this module is only a skeleton and should not be used directly other than libp2p bundle implementors that want to extend its code.
Again, as noted above, this module is only a skeleton and should not be used directly other than libp2p bundle implementors that want to extend its code.
```sh
npm install --save libp2p
@ -56,11 +56,11 @@ npm install --save libp2p
## Usage
> **Disclamer - We haven't solidified [libp2p interface](https://github.com/libp2p/interface-libp2p) yet, it might change at anytime.**
> **Disclaimer - We haven't solidified [libp2p interface](https://github.com/libp2p/interface-libp2p) yet, it might change at anytime.**
### Extending libp2p skeleton
libp2p becomes very simple and basically acts as a glue for every module that compose this library. Since it can be highly customized, it requires some setup. What we recommend is to have a libp2p build for the system you are developing taking into account in your needs (e.g. for a browser working version of libp2p that acts as the network layer of IPFS, we have a built and minified version that browsers can require)
libp2p becomes very simple and basically acts as a glue for every module that compose this library. Since it can be highly customized, it requires some setup. What we recommend is to have a libp2p build for the system you are developing taking into account in your needs (e.g. for a browser working version of libp2p that acts as the network layer of IPFS, we have a built and minified version that browsers can require).
### libp2p API
@ -76,7 +76,7 @@ Defined by [interface-libp2p](https://github.com/libp2p/interface-libp2p)
### Packages
> List of packages currently in existance for libp2p
List of packages currently in existence for libp2p
| Package | Version | Dependencies | DevDependencies |
|---------|---------|--------------|-----------------|
@ -115,7 +115,7 @@ Defined by [interface-libp2p](https://github.com/libp2p/interface-libp2p)
## Contribute
THe libp2p implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out:
The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out:
- Go through the modules and **check out existing issues**. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrasture behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
- **Perform code reviews**. Most of this has been developed by @diasdavid, which means that more eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.

View File

@ -1,6 +1,6 @@
{
"name": "libp2p",
"version": "0.3.0",
"version": "0.5.2",
"description": "JavaScript Skeleton for libp2p bundles",
"main": "src/index.js",
"scripts": {
@ -32,24 +32,26 @@
"bugs": {
"url": "https://github.com/libp2p/js-libp2p/issues"
},
"homepage": "https://github.com/diasdavid/js-libp2p",
"homepage": "https://github.com/libp2p/js-libp2p",
"devDependencies": {
"chai": "^3.5.0",
"aegir": "^9.1.2",
"pre-commit": "^1.1.1"
"aegir": "^10.0.0",
"pre-commit": "^1.2.2"
},
"dependencies": {
"libp2p-swarm": "^0.26.3",
"mafmt": "^2.1.2",
"multiaddr": "^2.1.1",
"peer-book": "^0.3.0",
"peer-id": "^0.8.0",
"peer-info": "^0.8.1"
"libp2p-ping": "~0.3.0",
"libp2p-swarm": "~0.26.14",
"mafmt": "^2.1.6",
"multiaddr": "^2.2.1",
"peer-book": "~0.3.1",
"peer-id": "~0.8.2",
"peer-info": "~0.8.3"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Richard Littauer <richard.littauer@gmail.com>",
"greenkeeperio-bot <support@greenkeeper.io>"
"greenkeeperio-bot <support@greenkeeper.io>",
"mayerwin <mayerwin@users.noreply.github.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
@ -15,7 +16,7 @@ const OFFLINE_ERROR_MESSAGE = 'The libp2p node is not started yet'
const IPFS_CODE = 421
class Node {
constructor (_modules, _peerInfo, _peerBook) {
constructor (_modules, _peerInfo, _peerBook, _options) {
assert(_modules, 'requires modules to equip libp2p with features')
assert(_peerInfo, 'requires a PeerInfo instance')
@ -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,37 @@ class Node {
*/
stop (callback) {
this.isOnline = false
if (this.modules.discovery) {
this.modules.discovery.forEach((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
//