mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-29 15:31:56 +00:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
71dcaafcac | ||
|
5319e065ec | ||
|
f3801f0e6c | ||
|
51cc993876 | ||
|
a800c1ad91 | ||
|
54c474de98 | ||
|
f28dffb268 | ||
|
c049074cb5 |
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,3 +1,23 @@
|
|||||||
|
<a name="0.25.2"></a>
|
||||||
|
## [0.25.2](https://github.com/libp2p/js-libp2p/compare/v0.25.1...v0.25.2) (2019-04-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* dht config ([#359](https://github.com/libp2p/js-libp2p/issues/359)) ([f3801f0](https://github.com/libp2p/js-libp2p/commit/f3801f0))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="0.25.1"></a>
|
||||||
|
## [0.25.1](https://github.com/libp2p/js-libp2p/compare/v0.25.0...v0.25.1) (2019-04-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* bail when discovering self ([#357](https://github.com/libp2p/js-libp2p/issues/357)) ([f28dffb](https://github.com/libp2p/js-libp2p/commit/f28dffb))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="0.25.0"></a>
|
<a name="0.25.0"></a>
|
||||||
# [0.25.0](https://github.com/libp2p/js-libp2p/compare/v0.25.0-rc.6...v0.25.0) (2019-04-12)
|
# [0.25.0](https://github.com/libp2p/js-libp2p/compare/v0.25.0-rc.6...v0.25.0) (2019-04-12)
|
||||||
|
|
||||||
|
@@ -181,7 +181,11 @@ class Node extends libp2p {
|
|||||||
dht: {
|
dht: {
|
||||||
kBucketSize: 20,
|
kBucketSize: 20,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
enabledDiscovery: true // Allows to disable discovery (enabled by default)
|
randomWalk: {
|
||||||
|
enabled: true, // Allows to disable discovery (enabled by default)
|
||||||
|
interval: 300e3,
|
||||||
|
timeout: 10e3
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// Enable/Disable Experimental features
|
// Enable/Disable Experimental features
|
||||||
EXPERIMENTAL: { // Experimental features ("behind a flag")
|
EXPERIMENTAL: { // Experimental features ("behind a flag")
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
- [ ] Twitter
|
- [ ] Twitter
|
||||||
- [ ] IRC
|
- [ ] IRC
|
||||||
- [ ] Reddit
|
- [ ] Reddit
|
||||||
- [ ] [discuss.ipfs.io](https://discuss.ipfs.io/c/announcements)
|
- [ ] [discuss.libp2p.io](https://discuss.libp2p.io/c/news)
|
||||||
- [ ] Blog post
|
- [ ] Blog post
|
||||||
- [ ] Copy release notes to the [GitHub Release description](https://github.com/libp2p/js-libp2p/releases)
|
- [ ] Copy release notes to the [GitHub Release description](https://github.com/libp2p/js-libp2p/releases)
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ In alphabetical order, here are all the humans that contributed to the release:
|
|||||||
|
|
||||||
Would you like to contribute to the libp2p project and don't know how? Well, there are a few places you can get started:
|
Would you like to contribute to the libp2p project and don't know how? Well, there are a few places you can get started:
|
||||||
|
|
||||||
- Check the issues with the `help wanted` label at the Ready column in our waffle board - https://waffle.io/libp2p/js-libp2p?label=help%20wanted
|
- Check the issues with the `help wanted` label in the [libp2p repo](https://github.com/libp2p/js-libp2p/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
|
||||||
- Join an IPFS All Hands, introduce yourself and let us know where you would like to contribute - https://github.com/ipfs/team-mgmt#all-hands-call
|
- Join an IPFS All Hands, introduce yourself and let us know where you would like to contribute - https://github.com/ipfs/team-mgmt#all-hands-call
|
||||||
- Hack with IPFS and show us what you made! The All Hands call is also the perfect venue for demos, join in and show us what you built
|
- Hack with IPFS and show us what you made! The All Hands call is also the perfect venue for demos, join in and show us what you built
|
||||||
- Join the discussion at http://discuss.ipfs.io/ and help users finding their answers.
|
- Join the discussion at http://discuss.ipfs.io/ and help users finding their answers.
|
||||||
@@ -55,4 +55,4 @@ Would you like to contribute to the libp2p project and don't know how? Well, the
|
|||||||
|
|
||||||
# ⁉️ Do you have questions?
|
# ⁉️ Do you have questions?
|
||||||
|
|
||||||
The best place to ask your questions about libp2p, how it works and what you can do with it is at [discuss.ipfs.io](http://discuss.ipfs.io). We are also available at the #libp2p channel on Freenode.
|
The best place to ask your questions about libp2p, how it works and what you can do with it is at [discuss.libp2p.io](https://discuss.libp2p.io). We are also available at the #libp2p channel on Freenode.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "libp2p",
|
"name": "libp2p",
|
||||||
"version": "0.25.0",
|
"version": "0.25.2",
|
||||||
"description": "JavaScript base class for libp2p bundles",
|
"description": "JavaScript base class for libp2p bundles",
|
||||||
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
|
@@ -48,28 +48,16 @@ const configSchema = s({
|
|||||||
enabled: true
|
enabled: true
|
||||||
}),
|
}),
|
||||||
// DHT config
|
// DHT config
|
||||||
dht: s({
|
dht: s('object?', {
|
||||||
kBucketSize: 'number',
|
|
||||||
enabled: 'boolean?',
|
|
||||||
validators: 'object?',
|
|
||||||
selectors: 'object?',
|
|
||||||
randomWalk: optional(s({
|
|
||||||
enabled: 'boolean?',
|
|
||||||
queriesPerPeriod: 'number?',
|
|
||||||
interval: 'number?',
|
|
||||||
timeout: 'number?'
|
|
||||||
}, {
|
|
||||||
// random walk defaults
|
|
||||||
enabled: false, // disabled waiting for https://github.com/libp2p/js-libp2p-kad-dht/issues/86
|
|
||||||
queriesPerPeriod: 1,
|
|
||||||
interval: 30000,
|
|
||||||
timeout: 10000
|
|
||||||
}))
|
|
||||||
}, {
|
|
||||||
// DHT defaults
|
// DHT defaults
|
||||||
enabled: false,
|
enabled: false,
|
||||||
kBucketSize: 20,
|
kBucketSize: 20,
|
||||||
enabledDiscovery: false
|
randomWalk: {
|
||||||
|
enabled: false, // disabled waiting for https://github.com/libp2p/js-libp2p-kad-dht/issues/86
|
||||||
|
queriesPerPeriod: 1,
|
||||||
|
interval: 300e3,
|
||||||
|
timeout: 10e3
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
// Experimental config
|
// Experimental config
|
||||||
EXPERIMENTAL: s({
|
EXPERIMENTAL: s({
|
||||||
@@ -78,11 +66,7 @@ const configSchema = s({
|
|||||||
// Experimental defaults
|
// Experimental defaults
|
||||||
pubsub: false
|
pubsub: false
|
||||||
})
|
})
|
||||||
}, {
|
}, {})
|
||||||
relay: {},
|
|
||||||
dht: {},
|
|
||||||
EXPERIMENTAL: {}
|
|
||||||
})
|
|
||||||
|
|
||||||
const optionsSchema = s({
|
const optionsSchema = s({
|
||||||
switch: 'object?',
|
switch: 'object?',
|
||||||
|
@@ -7,5 +7,7 @@ exports.messages = {
|
|||||||
|
|
||||||
exports.codes = {
|
exports.codes = {
|
||||||
DHT_DISABLED: 'ERR_DHT_DISABLED',
|
DHT_DISABLED: 'ERR_DHT_DISABLED',
|
||||||
PUBSUB_NOT_STARTED: 'ERR_PUBSUB_NOT_STARTED'
|
PUBSUB_NOT_STARTED: 'ERR_PUBSUB_NOT_STARTED',
|
||||||
|
ERR_NODE_NOT_STARTED: 'ERR_NODE_NOT_STARTED',
|
||||||
|
ERR_DISCOVERED_SELF: 'ERR_DISCOVERED_SELF'
|
||||||
}
|
}
|
||||||
|
@@ -24,11 +24,12 @@ const dht = require('./dht')
|
|||||||
const pubsub = require('./pubsub')
|
const pubsub = require('./pubsub')
|
||||||
const getPeerInfo = require('./get-peer-info')
|
const getPeerInfo = require('./get-peer-info')
|
||||||
const validateConfig = require('./config').validate
|
const validateConfig = require('./config').validate
|
||||||
|
const { codes } = require('./errors')
|
||||||
|
|
||||||
const notStarted = (action, state) => {
|
const notStarted = (action, state) => {
|
||||||
return errCode(
|
return errCode(
|
||||||
new Error(`libp2p cannot ${action} when not started; state is ${state}`),
|
new Error(`libp2p cannot ${action} when not started; state is ${state}`),
|
||||||
'ERR_NODE_NOT_STARTED'
|
codes.ERR_NODE_NOT_STARTED
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,6 +477,10 @@ class Node extends EventEmitter {
|
|||||||
* @param {PeerInfo} peerInfo
|
* @param {PeerInfo} peerInfo
|
||||||
*/
|
*/
|
||||||
_peerDiscovered (peerInfo) {
|
_peerDiscovered (peerInfo) {
|
||||||
|
if (peerInfo.id.toB58String() === this.peerInfo.id.toB58String()) {
|
||||||
|
log.error(new Error(codes.ERR_DISCOVERED_SELF))
|
||||||
|
return
|
||||||
|
}
|
||||||
peerInfo = this.peerBook.put(peerInfo)
|
peerInfo = this.peerBook.put(peerInfo)
|
||||||
|
|
||||||
if (!this.isStarted()) return
|
if (!this.isStarted()) return
|
||||||
|
@@ -91,7 +91,7 @@ describe('configuration', () => {
|
|||||||
randomWalk: {
|
randomWalk: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
queriesPerPeriod: 1,
|
queriesPerPeriod: 1,
|
||||||
interval: 30000,
|
interval: 300000,
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -153,7 +153,7 @@ describe('configuration', () => {
|
|||||||
randomWalk: {
|
randomWalk: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
queriesPerPeriod: 1,
|
queriesPerPeriod: 1,
|
||||||
interval: 30000,
|
interval: 300000,
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -242,7 +242,7 @@ describe('configuration', () => {
|
|||||||
expect(() => validateConfig(options)).to.throw()
|
expect(() => validateConfig(options)).to.throw()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should add defaults, validators and selectors for dht', () => {
|
it('should be able to add validators and selectors for dht', () => {
|
||||||
const selectors = {}
|
const selectors = {}
|
||||||
const validators = {}
|
const validators = {}
|
||||||
|
|
||||||
@@ -283,14 +283,6 @@ describe('configuration', () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
dht: {
|
dht: {
|
||||||
kBucketSize: 20,
|
|
||||||
enabled: false,
|
|
||||||
randomWalk: {
|
|
||||||
enabled: false,
|
|
||||||
queriesPerPeriod: 1,
|
|
||||||
interval: 30000,
|
|
||||||
timeout: 10000
|
|
||||||
},
|
|
||||||
selectors,
|
selectors,
|
||||||
validators
|
validators
|
||||||
}
|
}
|
||||||
@@ -298,4 +290,43 @@ describe('configuration', () => {
|
|||||||
}
|
}
|
||||||
expect(validateConfig(options)).to.deep.equal(expected)
|
expect(validateConfig(options)).to.deep.equal(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should support new properties for the dht config', () => {
|
||||||
|
const options = {
|
||||||
|
peerInfo,
|
||||||
|
modules: {
|
||||||
|
transport: [WS],
|
||||||
|
dht: DHT
|
||||||
|
},
|
||||||
|
config: {
|
||||||
|
dht: {
|
||||||
|
kBucketSize: 20,
|
||||||
|
enabled: false,
|
||||||
|
myNewDHTConfigProperty: true,
|
||||||
|
randomWalk: {
|
||||||
|
enabled: false,
|
||||||
|
queriesPerPeriod: 1,
|
||||||
|
interval: 300000,
|
||||||
|
timeout: 10000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const expected = {
|
||||||
|
kBucketSize: 20,
|
||||||
|
enabled: false,
|
||||||
|
myNewDHTConfigProperty: true,
|
||||||
|
randomWalk: {
|
||||||
|
enabled: false,
|
||||||
|
queriesPerPeriod: 1,
|
||||||
|
interval: 300000,
|
||||||
|
timeout: 10000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const actual = validateConfig(options).config.dht
|
||||||
|
|
||||||
|
expect(actual).to.deep.equal(expected)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@@ -259,6 +259,33 @@ describe('peer discovery', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('discovery scenarios', () => {
|
||||||
|
setup({
|
||||||
|
config: {
|
||||||
|
dht: {
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
peerDiscovery: {
|
||||||
|
autoDial: false,
|
||||||
|
bootstrap: {
|
||||||
|
enabled: true,
|
||||||
|
list: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should ignore self on discovery', function () {
|
||||||
|
const discoverySpy = sinon.spy()
|
||||||
|
nodeA.on('peer:discovery', discoverySpy)
|
||||||
|
nodeA._discovery[0].emit('peer', nodeA.peerInfo)
|
||||||
|
|
||||||
|
expect(discoverySpy.called).to.eql(false)
|
||||||
|
expect(nodeA.peerBook.getAllArray()).to.have.length(0)
|
||||||
|
expect()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('MulticastDNS', () => {
|
describe('MulticastDNS', () => {
|
||||||
setup({
|
setup({
|
||||||
config: {
|
config: {
|
||||||
|
Reference in New Issue
Block a user