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

Commit e49143e

Browse files
authored
Merge branch 'master' into fix/dns-cache-and-http-throttling-in-browser
2 parents 62dbdc3 + 27751cf commit e49143e

20 files changed

+56
-61
lines changed

Diff for: README.md

-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ Configure remote preload nodes. The remote will preload content added on this no
328328
329329
Enable and configure experimental features.
330330
331-
- `pubsub` (boolean): Enable libp2p pub-sub. (Default: `false`)
332331
- `ipnsPubsub` (boolean): Enable pub-sub on IPNS. (Default: `false`)
333332
- `sharding` (boolean): Enable directory sharding. Directories that have many child objects will be represented by multiple DAG nodes instead of just one. It can improve lookup performance when a directory has several thousand files or more. (Default: `false`)
334333

Diff for: doc/config.md

+6
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ A string value for specifying which pubsub routing protocol to use. You can eith
180180

181181
Default: `gossipsub`
182182

183+
### `Enabled`
184+
185+
A boolean value for wether or not pubsub router should be active.
186+
187+
Default: `true`
188+
183189
## `Swarm`
184190

185191
Options for configuring the swarm.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@
195195
"execa": "^2.0.4",
196196
"form-data": "^2.5.1",
197197
"hat": "0.0.3",
198-
"ipfsd-ctl": "~0.45.0",
199198
"interface-ipfs-core": "^0.113.0",
199+
"ipfsd-ctl": "~0.46.0",
200200
"libp2p-websocket-star": "~0.10.2",
201201
"ncp": "^2.0.0",
202202
"p-event": "^4.1.0",

Diff for: src/cli/commands/daemon.js

-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ module.exports = {
1717
type: 'boolean',
1818
default: false
1919
})
20-
.option('enable-pubsub', {
21-
alias: 'enable-pubsub-experiment',
22-
type: 'boolean',
23-
default: false
24-
})
2520
.option('offline', {
2621
type: 'boolean',
2722
desc: 'Run offline. Do not connect to the rest of the network but provide local API.',
@@ -55,7 +50,6 @@ module.exports = {
5550
offline: argv.offline,
5651
pass: argv.pass,
5752
preload: { enabled: argv.enablePreload },
58-
pubsub: { enabled: argv.enablePubsub },
5953
EXPERIMENTAL: {
6054
ipnsPubsub: argv.enableNamesysPubsub,
6155
dht: argv.enableDhtExperiment,

Diff for: src/cli/utils.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ exports.getIPFS = (argv, callback) => {
4949
repo: exports.getRepoPath(),
5050
init: false,
5151
start: false,
52-
pass: argv.pass,
53-
pubsub: {
54-
enabled: true
55-
}
52+
pass: argv.pass
5653
})
5754

5855
const cleanup = promisify((cb) => {

Diff for: src/core/components/libp2p.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
119119
}
120120
},
121121
pubsub: {
122-
enabled: get(options, 'pubsub.enabled', false)
122+
enabled: get(config, 'Pubsub.Enabled', true)
123123
}
124124
},
125125
connectionManager: get(options, 'connectionManager',

Diff for: src/core/config.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ const configSchema = s({
3232
enabled: 'boolean?',
3333
addresses: optional(s(['multiaddr'])),
3434
interval: 'number?'
35-
}, { // defaults
36-
enabled: !isTest, // preload by default, unless in test env
37-
interval: 30 * 1000
38-
}),
39-
pubsub: optional(s({
40-
enabled: 'boolean?'
41-
})),
35+
}, { enabled: !isTest, interval: 30 * 1000 }),
4236
init: optional(union(['boolean', s({
4337
bits: 'number?',
4438
emptyRepo: 'boolean?',
@@ -76,7 +70,8 @@ const configSchema = s({
7670
})),
7771
Bootstrap: optional(s(['multiaddr-ipfs'])),
7872
Pubsub: optional(s({
79-
Router: 'string?'
73+
Router: 'string?',
74+
Enabled: 'boolean?'
8075
})),
8176
Swarm: optional(s({
8277
ConnMgr: optional(s({

Diff for: src/core/index.js

-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const multihashing = require('multihashing-async')
1515
const CID = require('cids')
1616
const debug = require('debug')
1717
const mergeOptions = require('merge-options')
18-
const get = require('dlv')
1918
const EventEmitter = require('events')
2019

2120
const config = require('./config')
@@ -48,9 +47,6 @@ class IPFS extends EventEmitter {
4847
init: true,
4948
start: true,
5049
EXPERIMENTAL: {},
51-
pubsub: {
52-
enabled: false
53-
},
5450
preload: {
5551
enabled: !isTest, // preload by default, unless in test env
5652
addresses: [
@@ -136,16 +132,7 @@ class IPFS extends EventEmitter {
136132
this.stats = components.stats(this)
137133
this.resolve = components.resolve(this)
138134

139-
if (this._options.pubsub.enabled) {
140-
this.log('pubsub is enabled')
141-
}
142135
if (this._options.EXPERIMENTAL.ipnsPubsub) {
143-
// if (!this._options.pubsub.enabled) {
144-
if (!get(this._options, 'pubsub.enabled', false)) {
145-
this.log('pubsub is enabled to use EXPERIMENTAL IPNS pubsub')
146-
this._options.pubsub.enabled = true
147-
}
148-
149136
this.log('EXPERIMENTAL IPNS pubsub is enabled')
150137
}
151138
if (this._options.EXPERIMENTAL.sharding) {

Diff for: src/core/runtime/config-browser.js

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ module.exports = () => ({
2727
'/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic',
2828
'/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6'
2929
],
30+
Pubsub: {
31+
Enabled: true
32+
},
3033
Swarm: {
3134
ConnMgr: {
3235
LowWater: 200,

Diff for: src/core/runtime/config-nodejs.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ module.exports = () => ({
4141
'/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6'
4242
],
4343
Pubsub: {
44-
Router: 'gossipsub'
44+
Router: 'gossipsub',
45+
Enabled: true
4546
},
4647
Swarm: {
4748
ConnMgr: {

Diff for: src/core/runtime/libp2p-browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Node extends libp2p {
6767
enabled: false
6868
},
6969
pubsub: {
70-
enabled: false,
70+
enabled: true,
7171
emitSelf: true
7272
}
7373
}

Diff for: src/core/runtime/libp2p-nodejs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Node extends libp2p {
7070
}
7171
},
7272
pubsub: {
73-
enabled: false,
73+
enabled: true,
7474
emitSelf: true
7575
}
7676
}

Diff for: test/cli/pubsub.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ describe('pubsub', function () {
4343
ipfsdA = await df.spawn({
4444
exec: IPFS,
4545
initOptions: { bits: 512 },
46-
config,
47-
args: ['--enable-pubsub']
46+
config
4847
})
4948
node = ipfsdA.api
5049
})
@@ -59,7 +58,6 @@ describe('pubsub', function () {
5958
const df = DaemonFactory.create({ type: 'js' })
6059
ipfsdB = await df.spawn({
6160
initOptions: { bits: 512 },
62-
args: ['--enable-pubsub'],
6361
exec: path.resolve(`${__dirname}/../../src/cli/bin.js`),
6462
config
6563
})

Diff for: test/core/config.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ describe('config', () => {
154154
{ config: { Swarm: { ConnMgr: undefined } } },
155155
{ config: { Swarm: undefined } },
156156

157+
{ config: { Pubsub: { Enabled: true, Router: 'gossipsub' } } },
158+
{ config: { Pubsub: { Enabled: false } } },
159+
157160
{ config: undefined }
158161
]
159162

@@ -184,6 +187,8 @@ describe('config', () => {
184187
{ config: { Swarm: { ConnMgr: 138 } } },
185188
{ config: { Swarm: 138 } },
186189

190+
{ config: { Pubsub: { Enabled: 1 } } },
191+
187192
{ config: 138 }
188193
]
189194

Diff for: test/core/create-node.spec.js

+25
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,31 @@ describe('create node', function () {
387387
})
388388
})
389389

390+
it('disable pubsub', function (done) {
391+
this.timeout(80 * 1000)
392+
393+
if (!isNode) { return done() }
394+
395+
const node = new IPFS({
396+
repo: tempRepo,
397+
init: { bits: 512 },
398+
config: {
399+
Pubsub: {
400+
Enabled: false
401+
}
402+
}
403+
})
404+
405+
node.once('start', (err) => {
406+
expect(err).to.not.exist()
407+
node.pubsub.peers('topic', (err) => {
408+
expect(err).to.exist()
409+
expect(err.code).to.equal('ERR_PUBSUB_DISABLED')
410+
node.stop(done)
411+
})
412+
})
413+
})
414+
390415
it('start and stop, start and stop', function (done) {
391416
this.timeout(80 * 1000)
392417

Diff for: test/core/interface.spec.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,10 @@ describe('interface-ipfs-core tests', function () {
147147

148148
tests.pubsub(CommonFactory.create({
149149
spawnOptions: {
150-
args: ['--enable-pubsub'],
151150
initOptions: { bits: 512 }
152151
}
153152
}), {
154-
skip: isNode ? [
155-
{
156-
name: 'should publish message from string',
157-
reason: 'not implemented'
158-
}
159-
] : {
153+
skip: isNode ? null : {
160154
reason: 'FIXME: disabled because no swarm addresses'
161155
}
162156
})

Diff for: test/core/libp2p.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('libp2p customization', function () {
148148
}
149149
},
150150
pubsub: {
151-
enabled: false,
151+
enabled: true,
152152
emitSelf: true,
153153
signMessages: true,
154154
strictSigning: true

Diff for: test/core/pubsub.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ describe('pubsub disabled', () => {
2424
config: {
2525
Addresses: {
2626
Swarm: []
27+
},
28+
Pubsub: {
29+
Enabled: false
2730
}
2831
},
2932
preload: {
3033
enabled: false
31-
},
32-
pubsub: {
33-
enabled: false
3434
}
3535
})
3636

Diff for: test/http-api/interface.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,9 @@ describe('interface-ipfs-core over ipfs-http-client tests', () => {
147147

148148
tests.pubsub(CommonFactory.create({
149149
spawnOptions: {
150-
args: ['--enable-pubsub'],
151150
initOptions: { bits: 512 }
152151
}
153-
}), {
154-
skip: [
155-
{
156-
name: 'should publish message from string',
157-
reason: 'not implemented'
158-
}
159-
]
160-
})
152+
}))
161153

162154
tests.repo(defaultCommonFactory)
163155

Diff for: test/http-api/routes.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ describe('HTTP API', () => {
2626
repo: repoTests,
2727
pass: hat(),
2828
config,
29-
pubsub: { enabled: true },
3029
preload: { enabled: false }
3130
})
3231
await ncp(repoExample, repoTests)

0 commit comments

Comments
 (0)