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

Commit b0acc71

Browse files
committed
fix: code review
1 parent f2e5a4d commit b0acc71

File tree

11 files changed

+20
-25
lines changed

11 files changed

+20
-25
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"form-data": "^2.3.3",
7373
"hat": "0.0.3",
7474
"interface-ipfs-core": "~0.96.0",
75-
"ipfsd-ctl": "~0.40.2",
75+
"ipfsd-ctl": "~0.41.0",
7676
"ncp": "^2.0.0",
7777
"qs": "^6.5.2",
7878
"rimraf": "^2.6.2",
@@ -128,7 +128,7 @@
128128
"joi": "^14.3.0",
129129
"joi-browser": "^13.4.0",
130130
"joi-multiaddr": "^4.0.0",
131-
"libp2p": "~0.24.3",
131+
"libp2p": "libp2p/js-libp2p#master",
132132
"libp2p-bootstrap": "~0.9.3",
133133
"libp2p-crypto": "~0.16.0",
134134
"libp2p-kad-dht": "~0.14.4",

src/cli/commands/daemon.js

-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ module.exports = {
2222
type: 'boolean',
2323
default: false
2424
})
25-
.option('enable-dht-experiment', {
26-
type: 'boolean',
27-
default: false
28-
})
2925
.option('offline', {
3026
desc: 'Run offline. Do not connect to the rest of the network but provide local API.',
3127
default: false

src/core/components/dht.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const PeerId = require('peer-id')
66
const PeerInfo = require('peer-info')
77
const CID = require('cids')
88
const each = require('async/each')
9-
const setImmediate = require('async/setImmediate')
9+
const nextTick = require('async/nextTick')
10+
1011
const errcode = require('err-code')
1112

1213
const debug = require('debug')
@@ -38,7 +39,7 @@ module.exports = (self) => {
3839
} catch (err) {
3940
log.error(err)
4041

41-
return setImmediate(() => callback(errcode(err, 'ERR_INVALID_CID')))
42+
return nextTick(() => callback(errcode(err, 'ERR_INVALID_CID')))
4243
}
4344
}
4445

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

67-
return setImmediate(() => callback(errcode(err, 'ERR_INVALID_CID')))
68+
return nextTick(() => callback(errcode(err, 'ERR_INVALID_CID')))
6869
}
6970
}
7071

@@ -95,7 +96,7 @@ module.exports = (self) => {
9596
} catch (err) {
9697
log.error(err)
9798

98-
return setImmediate(() => callback(errcode(err, 'ERR_INVALID_CID')))
99+
return nextTick(() => callback(errcode(err, 'ERR_INVALID_CID')))
99100
}
100101
}
101102

src/core/components/libp2p.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
7777
},
7878
dht: {
7979
kBucketSize: get(options, 'dht.kBucketSize', 20),
80+
enabled: get(options, 'dht.enabled', true) && !(get(options, 'local', false)),
8081
enabledDiscovery: get(options, 'dht.enabledDiscovery', true),
8182
validators: {
8283
ipns: ipnsUtils.validator
@@ -86,7 +87,6 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
8687
}
8788
},
8889
EXPERIMENTAL: {
89-
dht: !(get(options, 'local', false)),
9090
pubsub: get(options, 'EXPERIMENTAL.pubsub', false)
9191
}
9292
},

src/core/runtime/libp2p-browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ class Node extends libp2p {
5555
},
5656
dht: {
5757
kBucketSize: 20,
58+
enabled: false,
5859
enabledDiscovery: true
5960
},
6061
EXPERIMENTAL: {
61-
dht: true,
6262
pubsub: false
6363
}
6464
}

src/core/runtime/libp2p-nodejs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ class Node extends libp2p {
5454
},
5555
dht: {
5656
kBucketSize: 20,
57+
enabled: true,
5758
enabledDiscovery: true
5859
},
5960
EXPERIMENTAL: {
60-
dht: true,
6161
pubsub: false
6262
}
6363
}

src/http/api/resources/dht.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ exports.provide = {
144144
}).code(500)
145145
}
146146

147-
reply({})
147+
reply()
148148
})
149149
}
150150
}
@@ -176,7 +176,7 @@ exports.put = {
176176
}).code(500)
177177
}
178178

179-
reply({})
179+
reply()
180180
})
181181
}
182182
}

test/core/interface.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('interface-ipfs-core tests', function () {
102102

103103
tests.name(CommonFactory.create({
104104
spawnOptions: {
105-
args: ['--pass ipfs-is-awesome-software', '--local'],
105+
args: ['--pass ipfs-is-awesome-software', '--offline'],
106106
initOptions: { bits: 512 },
107107
config: {
108108
Bootstrap: [],

test/core/libp2p.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const PeerBook = require('peer-book')
1313
const WebSocketStar = require('libp2p-websocket-star')
1414
const Multiplex = require('libp2p-mplex')
1515
const SECIO = require('libp2p-secio')
16+
const KadDHT = require('libp2p-kad-dht')
1617
const Libp2p = require('libp2p')
1718

1819
const libp2pComponent = require('../../src/core/components/libp2p')
@@ -45,7 +46,6 @@ describe('libp2p customization', function () {
4546
}
4647
},
4748
EXPERIMENTAL: {
48-
dht: false,
4949
pubsub: false
5050
}
5151
}
@@ -94,7 +94,8 @@ describe('libp2p customization', function () {
9494
],
9595
peerDiscovery: [
9696
wsstar.discovery
97-
]
97+
],
98+
dht: KadDHT
9899
}
99100
})
100101
}
@@ -144,7 +145,6 @@ describe('libp2p customization', function () {
144145
}
145146
},
146147
EXPERIMENTAL: {
147-
dht: true,
148148
pubsub: false
149149
}
150150
})
@@ -172,7 +172,6 @@ describe('libp2p customization', function () {
172172
}
173173
},
174174
EXPERIMENTAL: {
175-
dht: false,
176175
pubsub: true
177176
},
178177
libp2p: {
@@ -209,7 +208,6 @@ describe('libp2p customization', function () {
209208
}
210209
},
211210
EXPERIMENTAL: {
212-
dht: true,
213211
pubsub: true
214212
}
215213
})

test/core/name.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('name', function () {
5050
this.timeout(50 * 1000)
5151
df.spawn({
5252
exec: IPFS,
53-
args: [`--pass ${hat()}`, '--local'],
53+
args: [`--pass ${hat()}`, '--offline'],
5454
config: { Bootstrap: [] }
5555
}, (err, _ipfsd) => {
5656
expect(err).to.not.exist()
@@ -152,7 +152,7 @@ describe('name', function () {
152152
this.timeout(40 * 1000)
153153
df.spawn({
154154
exec: IPFS,
155-
args: [`--pass ${hat()}`, '--local'],
155+
args: [`--pass ${hat()}`, '--offline'],
156156
config: { Bootstrap: [] }
157157
}, (err, _ipfsd) => {
158158
expect(err).to.not.exist()
@@ -474,7 +474,7 @@ describe('name', function () {
474474
this.timeout(40 * 1000)
475475
df.spawn({
476476
exec: IPFS,
477-
args: [`--pass ${hat()}`, '--local'],
477+
args: [`--pass ${hat()}`, '--offline'],
478478
config: {
479479
Bootstrap: [],
480480
Discovery: {

test/core/ping.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const config = {
2929
}
3030

3131
function spawnNode ({ dht = false, type = 'js' }, cb) {
32-
const args = dht ? [] : ['--local']
32+
const args = dht ? [] : ['--offline']
3333
const factory = type === 'js' ? df : dfProc
3434
factory.spawn({
3535
args,

0 commit comments

Comments
 (0)