Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
61966c0
test: enable pubsub tests
richardschneider Nov 16, 2017
534d849
fix: generate meaniful error when pubsub is called and not enabled
richardschneider Nov 17, 2017
12ec8d2
test: enable pubsub for factory daemon
richardschneider Nov 17, 2017
1e9f260
test: enable pubsub tests
richardschneider Nov 16, 2017
15ab7a2
fix: generate meaniful error when pubsub is called and not enabled
richardschneider Nov 17, 2017
dc5166c
test: enable pubsub for factory daemon
richardschneider Nov 17, 2017
718645d
fiix(pubsub-subscribe): stop HAPI gzip from buffering our streamed re…
richardschneider Nov 17, 2017
ad6d9a4
Merge branch 'pubsub' of https://github.com/ipfs/js-ipfs into pubsub
richardschneider Nov 17, 2017
533d803
test: fix spec/pubsub
richardschneider Nov 18, 2017
08955a2
fix: lint errors
richardschneider Nov 18, 2017
c5fda15
test: tests js/go pubsub interop
richardschneider Nov 18, 2017
c7c27a3
test: pubsub interop tests
richardschneider Nov 20, 2017
8c7eaf0
test: enable pubsub tests
richardschneider Nov 16, 2017
6c89ce4
fix: generate meaniful error when pubsub is called and not enabled
richardschneider Nov 17, 2017
63a7c5b
test: enable pubsub for factory daemon
richardschneider Nov 17, 2017
3d3363f
fiix(pubsub-subscribe): stop HAPI gzip from buffering our streamed re…
richardschneider Nov 17, 2017
42ceb4b
test: fix spec/pubsub
richardschneider Nov 18, 2017
b12e688
fix: lint errors
richardschneider Nov 18, 2017
bc0e1bd
test: tests js/go pubsub interop
richardschneider Nov 18, 2017
fb726a7
test: pubsub interop tests
richardschneider Nov 20, 2017
5bc9ce2
test: more tests with different data types
richardschneider Nov 21, 2017
97e619f
Merge branch 'pubsub' of https://github.com/ipfs/js-ipfs into pubsub
richardschneider Nov 21, 2017
9d83fa3
HTTP API server: parsing query string as binary in pubsub publish
pgte Nov 21, 2017
fc724e1
HTTP API: pubsub: publish should fail gracefully when no argument is …
pgte Nov 21, 2017
7b5dc81
chore: update deps
daviddias Nov 22, 2017
0c98a48
chore: update deps
daviddias Nov 22, 2017
18179d7
last pass
daviddias Nov 22, 2017
7cdaeec
Merge branch 'pubsub-cont' into pubsub
daviddias Nov 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/core/components/no-floodsub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'

const EventEmitter = require('events')

function fail() {
throw new Error('The daemon must be run with \'--enable-pubsub-experiment\'')
}

class NoFloodSub extends EventEmitter {
constructor () {
super()

this.peers = new Map()
this.subscriptions = new Set()
}

start (callback) { callback() }
stop (callback) { callback() }
publish () { fail() }
subscribe () { fail() }
unsubscribe () { fail() }

}

module.exports = NoFloodSub

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good approach!

11 changes: 5 additions & 6 deletions src/core/components/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const series = require('async/series')
const Bitswap = require('ipfs-bitswap')
const FloodSub = require('libp2p-floodsub')
const NoFloodSub = require('./no-floodsub')
const setImmediate = require('async/setImmediate')
const promisify = require('promisify-es6')

Expand Down Expand Up @@ -50,12 +51,10 @@ module.exports = (self) => {
self._bitswap.start()
self._blockService.setExchange(self._bitswap)

if (self._options.EXPERIMENTAL.pubsub) {
self._pubsub = new FloodSub(self._libp2pNode)
self._pubsub.start(done)
} else {
done()
}
self._pubsub = self._options.EXPERIMENTAL.pubsub
? new FloodSub(self._libp2pNode)
: new NoFloodSub()
self._pubsub.start(done)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

})
})
}
8 changes: 1 addition & 7 deletions src/core/components/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ module.exports = (self) => {
self._bitswap.stop()

series([
(cb) => {
if (self._options.EXPERIMENTAL.pubsub) {
self._pubsub.stop(cb)
} else {
cb()
}
},
(cb) => self._pubsub.stop(cb),
(cb) => self.libp2p.stop(cb),
(cb) => self._repo.close(cb)
], done)
Expand Down
2 changes: 1 addition & 1 deletion test/cli/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const createTempNode = ''
const repoPath = require('./index').repoPath
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe.skip('pubsub', () => {
describe('pubsub', () => {
const topicA = 'nonscentsA'
const topicB = 'nonscentsB'
const topicC = 'nonscentsC'
Expand Down
3 changes: 0 additions & 3 deletions test/http-api/interface/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

'use strict'

// TODO needs: https://github.com/ipfs/js-ipfs-api/pull/493
/*
const test = require('interface-ipfs-core')
const FactoryClient = require('./../../utils/ipfs-factory-daemon')

Expand All @@ -20,4 +18,3 @@ const common = {
}

test.pubsub(common)
*/
2 changes: 1 addition & 1 deletion test/http-api/spec/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const createTempNode = ''

// TODO migrate to use ipfs-factory-daemon
module.exports = (http) => {
describe.skip('/pubsub', () => {
describe('/pubsub', () => {
let api
let tmpNode

Expand Down
4 changes: 3 additions & 1 deletion test/utils/ipfs-factory-daemon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class Factory {
})
},
(cb) => {
daemon = new HttpApi(repoPath, config)
daemon = new HttpApi(repoPath, config, {
enablePubsubExperiment: true,
})
daemon.repoPath = repoPath
this.daemonsSpawned.push(daemon)

Expand Down