mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-09 05:41:33 +00:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
b5209fc456 | |||
932d8772da | |||
baee2b7945 | |||
153f8884fa | |||
b71f77dcf7 | |||
8dc8e0530b | |||
4ed0ce16af | |||
cbb7290a97 | |||
63b10c01e3 | |||
11c21b6999 | |||
109ee51d7b | |||
09182b43bf | |||
a130ab2dc1 | |||
13355bf179 | |||
e24a1e43dc | |||
cb7d60ef65 | |||
a01b9479eb | |||
d01876a3d1 | |||
eb5eed8b21 | |||
3c58613b69 | |||
5dd5d37f6a | |||
6c3dd4b780 | |||
06913271c7 | |||
2cdd7033f0 | |||
c2cf1da2ce | |||
8d0124ee5c |
5
CHANGELOG.md
Normal file
5
CHANGELOG.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<a name="0.5.5"></a>
|
||||||
|
## [0.5.5](https://github.com/libp2p/js-libp2p/compare/v0.5.4...v0.5.5) (2017-03-21)
|
||||||
|
|
||||||
|
|
||||||
|
|
12
README.md
12
README.md
@ -39,7 +39,7 @@ To sum up, libp2p is a "network stack" -- a protocol suite -- that cleanly separ
|
|||||||
|
|
||||||
## Bundles
|
## 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-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)
|
- [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
|
## 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
|
```sh
|
||||||
npm install --save libp2p
|
npm install --save libp2p
|
||||||
@ -56,11 +56,11 @@ npm install --save libp2p
|
|||||||
|
|
||||||
## Usage
|
## 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
|
### 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
|
### libp2p API
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ Defined by [interface-libp2p](https://github.com/libp2p/interface-libp2p)
|
|||||||
|
|
||||||
### Packages
|
### Packages
|
||||||
|
|
||||||
> List of packages currently in existance for libp2p
|
List of packages currently in existence for libp2p
|
||||||
|
|
||||||
| Package | Version | Dependencies | DevDependencies |
|
| Package | Version | Dependencies | DevDependencies |
|
||||||
|---------|---------|--------------|-----------------|
|
|---------|---------|--------------|-----------------|
|
||||||
@ -115,7 +115,7 @@ Defined by [interface-libp2p](https://github.com/libp2p/interface-libp2p)
|
|||||||
|
|
||||||
## Contribute
|
## 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.
|
- 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.
|
- **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.
|
||||||
|
26
package.json
26
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "libp2p",
|
"name": "libp2p",
|
||||||
"version": "0.3.1",
|
"version": "0.5.5",
|
||||||
"description": "JavaScript Skeleton for libp2p bundles",
|
"description": "JavaScript Skeleton for libp2p bundles",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -32,25 +32,27 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/libp2p/js-libp2p/issues"
|
"url": "https://github.com/libp2p/js-libp2p/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/diasdavid/js-libp2p",
|
"homepage": "https://github.com/libp2p/js-libp2p",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"aegir": "^11.0.0",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"aegir": "^9.1.2",
|
"dirty-chai": "^1.2.2",
|
||||||
"pre-commit": "^1.1.1"
|
"pre-commit": "^1.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"libp2p-ping": "^0.3.0",
|
"libp2p-ping": "~0.3.2",
|
||||||
"libp2p-swarm": "^0.26.3",
|
"libp2p-swarm": "~0.26.19",
|
||||||
"mafmt": "^2.1.2",
|
"mafmt": "^2.1.6",
|
||||||
"multiaddr": "^2.1.1",
|
"multiaddr": "^2.2.2",
|
||||||
"peer-book": "^0.3.0",
|
"peer-book": "~0.3.1",
|
||||||
"peer-id": "^0.8.0",
|
"peer-id": "~0.8.4",
|
||||||
"peer-info": "^0.8.1"
|
"peer-info": "~0.8.4"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"David Dias <daviddias.p@gmail.com>",
|
"David Dias <daviddias.p@gmail.com>",
|
||||||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
||||||
"Richard Littauer <richard.littauer@gmail.com>",
|
"Richard Littauer <richard.littauer@gmail.com>",
|
||||||
"greenkeeperio-bot <support@greenkeeper.io>"
|
"greenkeeperio-bot <support@greenkeeper.io>",
|
||||||
|
"mayerwin <mayerwin@users.noreply.github.com>"
|
||||||
]
|
]
|
||||||
}
|
}
|
19
src/index.js
19
src/index.js
@ -9,6 +9,7 @@ const mafmt = require('mafmt')
|
|||||||
const EE = require('events').EventEmitter
|
const EE = require('events').EventEmitter
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const Ping = require('libp2p-ping')
|
const Ping = require('libp2p-ping')
|
||||||
|
const setImmediate = require('async/setImmediate')
|
||||||
|
|
||||||
exports = module.exports
|
exports = module.exports
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ const OFFLINE_ERROR_MESSAGE = 'The libp2p node is not started yet'
|
|||||||
const IPFS_CODE = 421
|
const IPFS_CODE = 421
|
||||||
|
|
||||||
class Node {
|
class Node {
|
||||||
constructor (_modules, _peerInfo, _peerBook) {
|
constructor (_modules, _peerInfo, _peerBook, _options) {
|
||||||
assert(_modules, 'requires modules to equip libp2p with features')
|
assert(_modules, 'requires modules to equip libp2p with features')
|
||||||
assert(_peerInfo, 'requires a PeerInfo instance')
|
assert(_peerInfo, 'requires a PeerInfo instance')
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ class Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attach discovery mechanisms
|
// Attach discovery mechanisms
|
||||||
if (this.discovery) {
|
if (this.modules.discovery) {
|
||||||
let discoveries = this.modules.discovery
|
let discoveries = this.modules.discovery
|
||||||
discoveries = Array.isArray(discoveries) ? discoveries : [discoveries]
|
discoveries = Array.isArray(discoveries) ? discoveries : [discoveries]
|
||||||
discoveries.forEach((discovery) => {
|
discoveries.forEach((discovery) => {
|
||||||
@ -115,6 +116,13 @@ class Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.isOnline = true
|
this.isOnline = true
|
||||||
|
|
||||||
|
if (this.modules.discovery) {
|
||||||
|
this.modules.discovery.forEach((discovery) => {
|
||||||
|
setImmediate(() => discovery.start(() => {}))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
callback()
|
callback()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -124,6 +132,13 @@ class Node {
|
|||||||
*/
|
*/
|
||||||
stop (callback) {
|
stop (callback) {
|
||||||
this.isOnline = false
|
this.isOnline = false
|
||||||
|
|
||||||
|
if (this.modules.discovery) {
|
||||||
|
this.modules.discovery.forEach((discovery) => {
|
||||||
|
setImmediate(() => discovery.stop(() => {}))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
this.swarm.close(callback)
|
this.swarm.close(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
chai.use(require('dirty-chai'))
|
||||||
|
const expect = chai.expect
|
||||||
|
|
||||||
const libp2p = require('../src')
|
const libp2p = require('../src')
|
||||||
|
|
||||||
describe('libp2p', () => {
|
describe('libp2p', () => {
|
||||||
it('the skeleton is fine, now go build your own libp2p bundle', () => {
|
it('the skeleton is fine, now go build your own libp2p bundle', () => {
|
||||||
expect(libp2p).to.exist
|
expect(libp2p).to.exist()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user