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

Commit

Permalink
chore: address review
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Sep 2, 2019
1 parent 011827d commit 2e44237
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 31 deletions.
4 changes: 2 additions & 2 deletions examples/circuit-relaying/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-libp2p/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-libp2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions examples/exchange-files-in-browser/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ let info
async function start () {
if (!node) {
const options = {
EXPERIMENTAL: {
pubsub: true
pubsub: {
enabled: true
},
repo: 'ipfs-' + Math.random(),
config: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
type: 'boolean',
default: false
})
.option('enable-pubsub-experiment', {
.option('enable-pubsub', {
type: 'boolean',
default: false
})
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cli/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ exports.getIPFS = (argv, callback) => {
init: false,
start: false,
pass: argv.pass,
EXPERIMENTAL: {
pubsub: true
pubsub: {
enabled: true
}
})

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 @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?',
Expand Down
15 changes: 10 additions & 5 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -46,6 +47,9 @@ class IPFS extends EventEmitter {
init: true,
start: true,
EXPERIMENTAL: {},
pubsub: {
enabled: false
},
preload: {
enabled: true,
addresses: [
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions test/cli/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('pubsub', function () {
exec: IPFS,
initOptions: { bits: 512 },
config,
args: ['--enable-pubsub-experiment']
args: ['--enable-pubsub']
})
node = ipfsdA.api
})
Expand All @@ -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
})
Expand Down
5 changes: 2 additions & 3 deletions test/core/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
]

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

it('should validate invalid EXPERIMENTAL', () => {
const cfgs = [
{ EXPERIMENTAL: { pubsub: 138 } },
{ EXPERIMENTAL: { dht: 138 } },
{ EXPERIMENTAL: { sharding: 138 } }
]
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 @@ -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 }
}
}), {
Expand Down
4 changes: 2 additions & 2 deletions test/core/pubsub.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('pubsub disabled', () => {
preload: {
enabled: false
},
EXPERIMENTAL: {
pubsub: false
pubsub: {
enabled: false
}
})

Expand Down
2 changes: 1 addition & 1 deletion test/http-api/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}))
Expand Down
4 changes: 1 addition & 3 deletions test/http-api/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2e44237

Please sign in to comment.