Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Jan 30, 2019
1 parent f2e5a4d commit b0acc71
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 25 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"form-data": "^2.3.3",
"hat": "0.0.3",
"interface-ipfs-core": "~0.96.0",
"ipfsd-ctl": "~0.40.2",
"ipfsd-ctl": "~0.41.0",
"ncp": "^2.0.0",
"qs": "^6.5.2",
"rimraf": "^2.6.2",
Expand Down Expand Up @@ -128,7 +128,7 @@
"joi": "^14.3.0",
"joi-browser": "^13.4.0",
"joi-multiaddr": "^4.0.0",
"libp2p": "~0.24.3",
"libp2p": "libp2p/js-libp2p#master",
"libp2p-bootstrap": "~0.9.3",
"libp2p-crypto": "~0.16.0",
"libp2p-kad-dht": "~0.14.4",
Expand Down
4 changes: 0 additions & 4 deletions src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ module.exports = {
type: 'boolean',
default: false
})
.option('enable-dht-experiment', {
type: 'boolean',
default: false
})
.option('offline', {
desc: 'Run offline. Do not connect to the rest of the network but provide local API.',
default: false
Expand Down
9 changes: 5 additions & 4 deletions src/core/components/dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const CID = require('cids')
const each = require('async/each')
const setImmediate = require('async/setImmediate')
const nextTick = require('async/nextTick')

const errcode = require('err-code')

const debug = require('debug')
Expand Down Expand Up @@ -38,7 +39,7 @@ module.exports = (self) => {
} catch (err) {
log.error(err)

return setImmediate(() => callback(errcode(err, 'ERR_INVALID_CID')))
return nextTick(() => callback(errcode(err, 'ERR_INVALID_CID')))
}
}

Expand All @@ -64,7 +65,7 @@ module.exports = (self) => {
} catch (err) {
log.error(err)

return setImmediate(() => callback(errcode(err, 'ERR_INVALID_CID')))
return nextTick(() => callback(errcode(err, 'ERR_INVALID_CID')))
}
}

Expand Down Expand Up @@ -95,7 +96,7 @@ module.exports = (self) => {
} catch (err) {
log.error(err)

return setImmediate(() => callback(errcode(err, 'ERR_INVALID_CID')))
return nextTick(() => callback(errcode(err, 'ERR_INVALID_CID')))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/components/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
},
dht: {
kBucketSize: get(options, 'dht.kBucketSize', 20),
enabled: get(options, 'dht.enabled', true) && !(get(options, 'local', false)),
enabledDiscovery: get(options, 'dht.enabledDiscovery', true),
validators: {
ipns: ipnsUtils.validator
Expand All @@ -86,7 +87,6 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
}
},
EXPERIMENTAL: {
dht: !(get(options, 'local', false)),
pubsub: get(options, 'EXPERIMENTAL.pubsub', false)
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/core/runtime/libp2p-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class Node extends libp2p {
},
dht: {
kBucketSize: 20,
enabled: false,
enabledDiscovery: true
},
EXPERIMENTAL: {
dht: true,
pubsub: false
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/runtime/libp2p-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class Node extends libp2p {
},
dht: {
kBucketSize: 20,
enabled: true,
enabledDiscovery: true
},
EXPERIMENTAL: {
dht: true,
pubsub: false
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/http/api/resources/dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ exports.provide = {
}).code(500)
}

reply({})
reply()
})
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ exports.put = {
}).code(500)
}

reply({})
reply()
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/core/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('interface-ipfs-core tests', function () {

tests.name(CommonFactory.create({
spawnOptions: {
args: ['--pass ipfs-is-awesome-software', '--local'],
args: ['--pass ipfs-is-awesome-software', '--offline'],
initOptions: { bits: 512 },
config: {
Bootstrap: [],
Expand Down
8 changes: 3 additions & 5 deletions test/core/libp2p.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const PeerBook = require('peer-book')
const WebSocketStar = require('libp2p-websocket-star')
const Multiplex = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
const KadDHT = require('libp2p-kad-dht')
const Libp2p = require('libp2p')

const libp2pComponent = require('../../src/core/components/libp2p')
Expand Down Expand Up @@ -45,7 +46,6 @@ describe('libp2p customization', function () {
}
},
EXPERIMENTAL: {
dht: false,
pubsub: false
}
}
Expand Down Expand Up @@ -94,7 +94,8 @@ describe('libp2p customization', function () {
],
peerDiscovery: [
wsstar.discovery
]
],
dht: KadDHT
}
})
}
Expand Down Expand Up @@ -144,7 +145,6 @@ describe('libp2p customization', function () {
}
},
EXPERIMENTAL: {
dht: true,
pubsub: false
}
})
Expand Down Expand Up @@ -172,7 +172,6 @@ describe('libp2p customization', function () {
}
},
EXPERIMENTAL: {
dht: false,
pubsub: true
},
libp2p: {
Expand Down Expand Up @@ -209,7 +208,6 @@ describe('libp2p customization', function () {
}
},
EXPERIMENTAL: {
dht: true,
pubsub: true
}
})
Expand Down
6 changes: 3 additions & 3 deletions test/core/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('name', function () {
this.timeout(50 * 1000)
df.spawn({
exec: IPFS,
args: [`--pass ${hat()}`, '--local'],
args: [`--pass ${hat()}`, '--offline'],
config: { Bootstrap: [] }
}, (err, _ipfsd) => {
expect(err).to.not.exist()
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('name', function () {
this.timeout(40 * 1000)
df.spawn({
exec: IPFS,
args: [`--pass ${hat()}`, '--local'],
args: [`--pass ${hat()}`, '--offline'],
config: { Bootstrap: [] }
}, (err, _ipfsd) => {
expect(err).to.not.exist()
Expand Down Expand Up @@ -474,7 +474,7 @@ describe('name', function () {
this.timeout(40 * 1000)
df.spawn({
exec: IPFS,
args: [`--pass ${hat()}`, '--local'],
args: [`--pass ${hat()}`, '--offline'],
config: {
Bootstrap: [],
Discovery: {
Expand Down
2 changes: 1 addition & 1 deletion test/core/ping.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const config = {
}

function spawnNode ({ dht = false, type = 'js' }, cb) {
const args = dht ? [] : ['--local']
const args = dht ? [] : ['--offline']
const factory = type === 'js' ? df : dfProc
factory.spawn({
args,
Expand Down

1 comment on commit b0acc71

@obelisk-dev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is DHT in the libp2p-browser default to false now?

Please sign in to comment.