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

Commit c21d362

Browse files
committed
chore: address review
1 parent 011827d commit c21d362

File tree

17 files changed

+36
-31
lines changed

17 files changed

+36
-31
lines changed

examples/circuit-relaying/src/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ document.addEventListener('DOMContentLoaded', async () => {
3636
enabled: true // make this node a relay (HOP)
3737
}
3838
},
39-
EXPERIMENTAL: {
40-
pubsub: true // enable pubsub
39+
pubsub: {
40+
enabled: true
4141
},
4242
config: {
4343
Bootstrap: []

examples/custom-libp2p/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ const libp2pBundle = (opts) => {
9696
timeout: 2e3 // End the query quickly since we're running so frequently
9797
}
9898
},
99-
EXPERIMENTAL: {
100-
pubsub: true
99+
pubsub: {
100+
enabled: true
101101
}
102102
}
103103
})

examples/custom-libp2p/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"license": "MIT",
1111
"dependencies": {
1212
"ipfs": "file:../../",
13-
"libp2p": "~0.25.0",
13+
"libp2p": "~0.26.1",
1414
"libp2p-bootstrap": "~0.9.7",
1515
"libp2p-kad-dht": "~0.15.0",
1616
"libp2p-mdns": "~0.12.2",

examples/exchange-files-in-browser/public/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ let info
4444
async function start () {
4545
if (!node) {
4646
const options = {
47-
EXPERIMENTAL: {
48-
pubsub: true
47+
pubsub: {
48+
enabled: true
4949
},
5050
repo: 'ipfs-' + Math.random(),
5151
config: {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
"form-data": "^2.5.1",
196196
"hat": "0.0.3",
197197
"interface-ipfs-core": "^0.111.0",
198-
"ipfsd-ctl": "^0.44.1",
198+
"ipfsd-ctl": "ipfs/js-ipfsd-ctl#fix/pubsub-flag-defaults",
199199
"libp2p-websocket-star": "~0.10.2",
200200
"ncp": "^2.0.0",
201201
"p-event": "^4.1.0",

src/cli/commands/daemon.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
type: 'boolean',
1717
default: false
1818
})
19-
.option('enable-pubsub-experiment', {
19+
.option('enable-pubsub', {
2020
type: 'boolean',
2121
default: false
2222
})
@@ -53,8 +53,8 @@ module.exports = {
5353
offline: argv.offline,
5454
pass: argv.pass,
5555
preload: { enabled: argv.enablePreload },
56+
pubsub: { enabled: argv.enablePubsub },
5657
EXPERIMENTAL: {
57-
pubsub: argv.enablePubsubExperiment,
5858
ipnsPubsub: argv.enableNamesysPubsub,
5959
dht: argv.enableDhtExperiment,
6060
sharding: argv.enableShardingExperiment

src/cli/daemon.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Daemon {
3030
async start () {
3131
this._log('starting')
3232

33-
const libp2p = { modules: {} }
33+
const libp2p = { modules: {}, config: {} }
3434

3535
// Attempt to use any of the WebRTC versions available globally
3636
let electronWebRTC

src/cli/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ exports.getIPFS = (argv, callback) => {
5050
init: false,
5151
start: false,
5252
pass: argv.pass,
53-
EXPERIMENTAL: {
54-
pubsub: true
53+
pubsub: {
54+
enabled: true
5555
}
5656
})
5757

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, 'EXPERIMENTAL.pubsub', false)
122+
enabled: get(options, 'pubsub.enabled', false)
123123
}
124124
},
125125
connectionManager: get(options, 'connectionManager',

src/core/config.js

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const configSchema = s({
3232
addresses: optional(s(['multiaddr'])),
3333
interval: 'number?'
3434
}, { enabled: true, interval: 30 * 1000 }),
35+
pubsub: optional(s({
36+
enabled: 'boolean?'
37+
})),
3538
init: optional(union(['boolean', s({
3639
bits: 'number?',
3740
emptyRepo: 'boolean?',

src/core/index.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ 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')
1819
const EventEmitter = require('events')
1920

2021
const config = require('./config')
@@ -46,6 +47,9 @@ class IPFS extends EventEmitter {
4647
init: true,
4748
start: true,
4849
EXPERIMENTAL: {},
50+
pubsub: {
51+
enabled: false
52+
},
4953
preload: {
5054
enabled: true,
5155
addresses: [
@@ -131,13 +135,14 @@ class IPFS extends EventEmitter {
131135
this.stats = components.stats(this)
132136
this.resolve = components.resolve(this)
133137

134-
if (this._options.EXPERIMENTAL.pubsub) {
135-
this.log('EXPERIMENTAL pubsub is enabled')
138+
if (this._options.pubsub.enabled) {
139+
this.log('pubsub is enabled')
136140
}
137141
if (this._options.EXPERIMENTAL.ipnsPubsub) {
138-
if (!this._options.EXPERIMENTAL.pubsub) {
139-
this.log('EXPERIMENTAL pubsub is enabled to use IPNS pubsub')
140-
this._options.EXPERIMENTAL.pubsub = true
142+
// if (!this._options.pubsub.enabled) {
143+
if (!get(this._options, 'pubsub.enabled', false)) {
144+
this.log('pubsub is enabled to use EXPERIMENTAL IPNS pubsub')
145+
this._options.pubsub.enabled = true
141146
}
142147

143148
this.log('EXPERIMENTAL IPNS pubsub is enabled')

test/cli/pubsub.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('pubsub', function () {
4444
exec: IPFS,
4545
initOptions: { bits: 512 },
4646
config,
47-
args: ['--enable-pubsub-experiment']
47+
args: ['--enable-pubsub']
4848
})
4949
node = ipfsdA.api
5050
})
@@ -59,7 +59,7 @@ describe('pubsub', function () {
5959
const df = DaemonFactory.create({ type: 'js' })
6060
ipfsdB = await df.spawn({
6161
initOptions: { bits: 512 },
62-
args: ['--enable-pubsub-experiment'],
62+
args: ['--enable-pubsub'],
6363
exec: path.resolve(`${__dirname}/../../src/cli/bin.js`),
6464
config
6565
})

test/core/config.spec.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ describe('config', () => {
9898

9999
it('should validate valid EXPERIMENTAL', () => {
100100
const cfgs = [
101-
{ EXPERIMENTAL: { pubsub: true, dht: true, sharding: true } },
102-
{ EXPERIMENTAL: { pubsub: false, dht: false, sharding: false } },
101+
{ EXPERIMENTAL: { dht: true, sharding: true } },
102+
{ EXPERIMENTAL: { dht: false, sharding: false } },
103103
{ EXPERIMENTAL: undefined }
104104
]
105105

@@ -108,7 +108,6 @@ describe('config', () => {
108108

109109
it('should validate invalid EXPERIMENTAL', () => {
110110
const cfgs = [
111-
{ EXPERIMENTAL: { pubsub: 138 } },
112111
{ EXPERIMENTAL: { dht: 138 } },
113112
{ EXPERIMENTAL: { sharding: 138 } }
114113
]

test/core/interface.spec.js

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

150150
tests.pubsub(CommonFactory.create({
151151
spawnOptions: {
152-
args: ['--enable-pubsub-experiment'],
152+
args: ['--enable-pubsub'],
153153
initOptions: { bits: 512 }
154154
}
155155
}), {

test/core/pubsub.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describe('pubsub disabled', () => {
2929
preload: {
3030
enabled: false
3131
},
32-
EXPERIMENTAL: {
33-
pubsub: false
32+
pubsub: {
33+
enabled: false
3434
}
3535
})
3636

test/http-api/interface.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('interface-ipfs-core over ipfs-http-client tests', () => {
148148

149149
tests.pubsub(CommonFactory.create({
150150
spawnOptions: {
151-
args: ['--enable-pubsub-experiment'],
151+
args: ['--enable-pubsub'],
152152
initOptions: { bits: 512 }
153153
}
154154
}))

test/http-api/routes.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ describe('HTTP API', () => {
2626
repo: repoTests,
2727
pass: hat(),
2828
config,
29-
EXPERIMENTAL: {
30-
pubsub: true
31-
},
29+
pubsub: { enabled: true },
3230
preload: { enabled: false }
3331
})
3432
await ncp(repoExample, repoTests)

0 commit comments

Comments
 (0)