diff --git a/examples/circuit-relaying/src/app.js b/examples/circuit-relaying/src/app.js index 290a57cf26..dd34347c1c 100644 --- a/examples/circuit-relaying/src/app.js +++ b/examples/circuit-relaying/src/app.js @@ -36,8 +36,8 @@ document.addEventListener('DOMContentLoaded', async () => { enabled: true // make this node a relay (HOP) } }, - EXPERIMENTAL: { - pubsub: true // enable pubsub + pubsub: { + enabled: true }, config: { Bootstrap: [] diff --git a/examples/custom-libp2p/index.js b/examples/custom-libp2p/index.js index 4b85fa2280..fa1a097b86 100644 --- a/examples/custom-libp2p/index.js +++ b/examples/custom-libp2p/index.js @@ -96,8 +96,8 @@ const libp2pBundle = (opts) => { timeout: 2e3 // End the query quickly since we're running so frequently } }, - EXPERIMENTAL: { - pubsub: true + pubsub: { + enabled: true } } }) diff --git a/examples/custom-libp2p/package.json b/examples/custom-libp2p/package.json index 81209e705b..944b8a2b7f 100644 --- a/examples/custom-libp2p/package.json +++ b/examples/custom-libp2p/package.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "ipfs": "file:../../", - "libp2p": "~0.25.0", + "libp2p": "~0.26.1", "libp2p-bootstrap": "~0.9.7", "libp2p-kad-dht": "~0.15.0", "libp2p-mdns": "~0.12.2", diff --git a/examples/exchange-files-in-browser/public/app.js b/examples/exchange-files-in-browser/public/app.js index 4578bc588d..d45f4c9b6e 100644 --- a/examples/exchange-files-in-browser/public/app.js +++ b/examples/exchange-files-in-browser/public/app.js @@ -44,8 +44,8 @@ let info async function start () { if (!node) { const options = { - EXPERIMENTAL: { - pubsub: true + pubsub: { + enabled: true }, repo: 'ipfs-' + Math.random(), config: { diff --git a/package.json b/package.json index 3253367d38..5102b9508d 100644 --- a/package.json +++ b/package.json @@ -195,7 +195,7 @@ "form-data": "^2.5.1", "hat": "0.0.3", "interface-ipfs-core": "^0.111.0", - "ipfsd-ctl": "^0.44.1", + "ipfsd-ctl": "~0.45.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0", "p-event": "^4.1.0", diff --git a/src/cli/commands/daemon.js b/src/cli/commands/daemon.js index 140ac2d224..804b298304 100644 --- a/src/cli/commands/daemon.js +++ b/src/cli/commands/daemon.js @@ -16,7 +16,7 @@ module.exports = { type: 'boolean', default: false }) - .option('enable-pubsub-experiment', { + .option('enable-pubsub', { type: 'boolean', default: false }) @@ -53,8 +53,8 @@ module.exports = { offline: argv.offline, pass: argv.pass, preload: { enabled: argv.enablePreload }, + pubsub: { enabled: argv.enablePubsub }, EXPERIMENTAL: { - pubsub: argv.enablePubsubExperiment, ipnsPubsub: argv.enableNamesysPubsub, dht: argv.enableDhtExperiment, sharding: argv.enableShardingExperiment diff --git a/src/cli/daemon.js b/src/cli/daemon.js index 879432018b..7181e8c1e7 100644 --- a/src/cli/daemon.js +++ b/src/cli/daemon.js @@ -30,7 +30,7 @@ class Daemon { async start () { this._log('starting') - const libp2p = { modules: {} } + const libp2p = { modules: {}, config: {} } // Attempt to use any of the WebRTC versions available globally let electronWebRTC diff --git a/src/cli/utils.js b/src/cli/utils.js index eed5cbdac6..0562ff6737 100644 --- a/src/cli/utils.js +++ b/src/cli/utils.js @@ -50,8 +50,8 @@ exports.getIPFS = (argv, callback) => { init: false, start: false, pass: argv.pass, - EXPERIMENTAL: { - pubsub: true + pubsub: { + enabled: true } }) diff --git a/src/core/components/libp2p.js b/src/core/components/libp2p.js index ef261f8c1c..ba420f120f 100644 --- a/src/core/components/libp2p.js +++ b/src/core/components/libp2p.js @@ -119,7 +119,7 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) { } }, pubsub: { - enabled: get(options, 'EXPERIMENTAL.pubsub', false) + enabled: get(options, 'pubsub.enabled', false) } }, connectionManager: get(options, 'connectionManager', diff --git a/src/core/config.js b/src/core/config.js index c259aa7451..53231bcc73 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -32,6 +32,9 @@ const configSchema = s({ addresses: optional(s(['multiaddr'])), interval: 'number?' }, { enabled: true, interval: 30 * 1000 }), + pubsub: optional(s({ + enabled: 'boolean?' + })), init: optional(union(['boolean', s({ bits: 'number?', emptyRepo: 'boolean?', diff --git a/src/core/index.js b/src/core/index.js index 8b0b717716..4016aa47fc 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -15,6 +15,7 @@ const multihashing = require('multihashing-async') const CID = require('cids') const debug = require('debug') const mergeOptions = require('merge-options') +const get = require('dlv') const EventEmitter = require('events') const config = require('./config') @@ -46,6 +47,9 @@ class IPFS extends EventEmitter { init: true, start: true, EXPERIMENTAL: {}, + pubsub: { + enabled: false + }, preload: { enabled: true, addresses: [ @@ -131,13 +135,14 @@ class IPFS extends EventEmitter { this.stats = components.stats(this) this.resolve = components.resolve(this) - if (this._options.EXPERIMENTAL.pubsub) { - this.log('EXPERIMENTAL pubsub is enabled') + if (this._options.pubsub.enabled) { + this.log('pubsub is enabled') } if (this._options.EXPERIMENTAL.ipnsPubsub) { - if (!this._options.EXPERIMENTAL.pubsub) { - this.log('EXPERIMENTAL pubsub is enabled to use IPNS pubsub') - this._options.EXPERIMENTAL.pubsub = true + // if (!this._options.pubsub.enabled) { + if (!get(this._options, 'pubsub.enabled', false)) { + this.log('pubsub is enabled to use EXPERIMENTAL IPNS pubsub') + this._options.pubsub.enabled = true } this.log('EXPERIMENTAL IPNS pubsub is enabled') diff --git a/test/cli/pubsub.js b/test/cli/pubsub.js index 89ae432bcd..e4358e90f2 100644 --- a/test/cli/pubsub.js +++ b/test/cli/pubsub.js @@ -44,7 +44,7 @@ describe('pubsub', function () { exec: IPFS, initOptions: { bits: 512 }, config, - args: ['--enable-pubsub-experiment'] + args: ['--enable-pubsub'] }) node = ipfsdA.api }) @@ -59,7 +59,7 @@ describe('pubsub', function () { const df = DaemonFactory.create({ type: 'js' }) ipfsdB = await df.spawn({ initOptions: { bits: 512 }, - args: ['--enable-pubsub-experiment'], + args: ['--enable-pubsub'], exec: path.resolve(`${__dirname}/../../src/cli/bin.js`), config }) diff --git a/test/core/config.spec.js b/test/core/config.spec.js index 8f2e643e1c..e67b077209 100644 --- a/test/core/config.spec.js +++ b/test/core/config.spec.js @@ -98,8 +98,8 @@ describe('config', () => { it('should validate valid EXPERIMENTAL', () => { const cfgs = [ - { EXPERIMENTAL: { pubsub: true, dht: true, sharding: true } }, - { EXPERIMENTAL: { pubsub: false, dht: false, sharding: false } }, + { EXPERIMENTAL: { dht: true, sharding: true } }, + { EXPERIMENTAL: { dht: false, sharding: false } }, { EXPERIMENTAL: undefined } ] @@ -108,7 +108,6 @@ describe('config', () => { it('should validate invalid EXPERIMENTAL', () => { const cfgs = [ - { EXPERIMENTAL: { pubsub: 138 } }, { EXPERIMENTAL: { dht: 138 } }, { EXPERIMENTAL: { sharding: 138 } } ] diff --git a/test/core/interface.spec.js b/test/core/interface.spec.js index f930641355..f2151a88df 100644 --- a/test/core/interface.spec.js +++ b/test/core/interface.spec.js @@ -149,7 +149,7 @@ describe('interface-ipfs-core tests', function () { tests.pubsub(CommonFactory.create({ spawnOptions: { - args: ['--enable-pubsub-experiment'], + args: ['--enable-pubsub'], initOptions: { bits: 512 } } }), { diff --git a/test/core/pubsub.spec.js b/test/core/pubsub.spec.js index c1a8ec9092..de0f4404c6 100644 --- a/test/core/pubsub.spec.js +++ b/test/core/pubsub.spec.js @@ -29,8 +29,8 @@ describe('pubsub disabled', () => { preload: { enabled: false }, - EXPERIMENTAL: { - pubsub: false + pubsub: { + enabled: false } }) diff --git a/test/http-api/interface.js b/test/http-api/interface.js index 8cbc2423ef..23b5916624 100644 --- a/test/http-api/interface.js +++ b/test/http-api/interface.js @@ -148,7 +148,7 @@ describe('interface-ipfs-core over ipfs-http-client tests', () => { tests.pubsub(CommonFactory.create({ spawnOptions: { - args: ['--enable-pubsub-experiment'], + args: ['--enable-pubsub'], initOptions: { bits: 512 } } })) diff --git a/test/http-api/routes.js b/test/http-api/routes.js index ded737cc6a..8c090727a5 100644 --- a/test/http-api/routes.js +++ b/test/http-api/routes.js @@ -26,9 +26,7 @@ describe('HTTP API', () => { repo: repoTests, pass: hat(), config, - EXPERIMENTAL: { - pubsub: true - }, + pubsub: { enabled: true }, preload: { enabled: false } }) await ncp(repoExample, repoTests)