Skip to content

Commit 6958239

Browse files
vasco-santoshugomrdias
authored andcommitted
feat: pubsub flag defaults (#363)
This PR points js-ipfs dependency to a PR in js-ipfs and because of that should be used with care!! A following PR should fix this shortly. BREAKING CHANGE: removes the experimental flag of pubsub and makes it enable by default
1 parent 9ba61d7 commit 6958239

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"dirty-chai": "^2.0.1",
8888
"go-ipfs-dep": "~0.4.22",
8989
"husky": "^3.0.4",
90-
"ipfs": "~0.37.1",
90+
"ipfs": "ipfs/js-ipfs#feat/gossipsub-as-default-pubsub",
9191
"is-running": "^2.1.0",
9292
"lint-staged": "^9.2.5",
9393
"proxyquire": "^2.1.3",

src/endpoint/routes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const routeConfig = {
1515
}
1616
}
1717

18-
let nodes = {}
18+
const nodes = {}
1919

2020
/**
2121
* @namespace EndpointServerRoutes

src/ipfsd-daemon.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const NON_DISPOSABLE_GRACE_PERIOD = 10500 * 3
2929

3030
function translateError (err) {
3131
// get the actual error message to be the err.message
32-
let message = err.message
32+
const message = err.message
3333
err.message = err.stderr
3434
err.stderr = message
3535

@@ -240,7 +240,7 @@ class Daemon {
240240

241241
let output = ''
242242

243-
return new Promise(async (resolve, reject) => {
243+
return new Promise(async (resolve, reject) => { // eslint-disable-line no-async-promise-executor
244244
this.subprocess = run(this, args, {
245245
env: this.env,
246246
stderr: (data) => {

src/ipfsd-in-proc.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ class InProc extends EventEmitter {
3939
pubsub: false,
4040
sharding: false
4141
})
42+
this.opts.pubsub = defaultsDeep({}, opts.pubsub, {
43+
enabled: false
44+
})
4245

4346
this.opts.args.forEach((arg) => {
4447
if (arg === '--enable-pubsub-experiment') {
4548
this.opts.EXPERIMENTAL.pubsub = true
4649
} else if (arg === '--enable-pubsub') {
47-
this.opts.pubsub = true
50+
this.opts.pubsub.enabled = true
4851
} else if (arg === '--enable-sharding-experiment') {
4952
this.opts.EXPERIMENTAL.sharding = true
5053
} else if (arg === '--enable-namesys-pubsub') {
@@ -68,6 +71,7 @@ class InProc extends EventEmitter {
6871
offline: this.opts.offline,
6972
EXPERIMENTAL: this.opts.EXPERIMENTAL,
7073
libp2p: this.opts.libp2p,
74+
pubsub: this.opts.pubsub,
7175
config: this.opts.config,
7276
relay: this.opts.relay
7377
})

test/npm-install.node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ types.forEach((type) => {
4141
})
4242

4343
it('has the correct path when installed with npm3', async () => {
44-
let execPath = type === 'js'
44+
const execPath = type === 'js'
4545
? 'ipfsd-ctl-test/node_modules/ipfs/src/cli'
4646
: 'ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs'
4747

48-
let npm3Path = path.join(tmp, execPath)
48+
const npm3Path = path.join(tmp, execPath)
4949

5050
await fs.mkdirp(npm3Path)
5151
fs.writeFileSync(path.join(npm3Path, appName))

test/spawn-options.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ describe('Spawn options', function () {
314314
this.timeout(20 * 1000)
315315

316316
const options = {
317-
args: ['--enable-pubsub-experiment'],
317+
args: [fOpts.type !== 'go' ? '--enable-pubsub' : '--enable-pubsub-experiment'],
318318
initOptions: { bits: fOpts.bits, profile: 'test' }
319319
}
320320

@@ -325,7 +325,7 @@ describe('Spawn options', function () {
325325
const topic = `test-topic-${hat()}`
326326
const data = Buffer.from('hey there')
327327

328-
return new Promise(async (resolve, reject) => {
328+
return new Promise(async (resolve, reject) => { // eslint-disable-line no-async-promise-executor
329329
const handler = (msg) => {
330330
try {
331331
expect(msg.data).to.eql(data)

0 commit comments

Comments
 (0)