This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 17 files changed +352
-76
lines changed
17 files changed +352
-76
lines changed Original file line number Diff line number Diff line change 33
33
"test:unit:node:gateway" : " aegir test -t node -f test/gateway/index.js" ,
34
34
"test:unit:node:cli" : " aegir test -t node -f test/cli/index.js" ,
35
35
"test:unit:browser" : " aegir test -t browser --no-cors" ,
36
- "test:interop" : " IPFS_TEST=interop aegir test -t node -t browser - f test/interop" ,
36
+ "test:interop" : " IPFS_TEST=interop aegir test -t node -f test/interop" ,
37
37
"test:interop:node" : " IPFS_TEST=interop aegir test -t node -f test/interop/node.js" ,
38
38
"test:interop:browser" : " IPFS_TEST=interop aegir test -t browser -f test/interop/browser.js" ,
39
39
"test:bootstrapers" : " IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js" ,
63
63
},
64
64
"homepage" : " https://github.com/ipfs/js-ipfs#readme" ,
65
65
"devDependencies" : {
66
- "aegir" : " ^12.1.3 " ,
66
+ "aegir" : " ^12.2.0 " ,
67
67
"buffer-loader" : " 0.0.1" ,
68
68
"chai" : " ^4.1.2" ,
69
69
"delay" : " ^2.0.0" ,
76
76
"form-data" : " ^2.3.1" ,
77
77
"hat" : " 0.0.3" ,
78
78
"interface-ipfs-core" : " ~0.36.7" ,
79
- "ipfsd-ctl" : " ~0.24 .1" ,
79
+ "ipfsd-ctl" : " ~0.25 .1" ,
80
80
"left-pad" : " ^1.2.0" ,
81
81
"lodash" : " ^4.17.4" ,
82
82
"mocha" : " ^4.0.1" ,
92
92
},
93
93
"dependencies" : {
94
94
"async" : " ^2.6.0" ,
95
+ "binary-querystring" : " ~0.1.2" ,
95
96
"bl" : " ^1.2.1" ,
96
97
"boom" : " ^7.1.1" ,
97
98
"bs58" : " ^4.0.1" ,
106
107
"hapi" : " ^16.6.2" ,
107
108
"hapi-set-header" : " ^1.0.2" ,
108
109
"hoek" : " ^5.0.2" ,
109
- "ipfs-api" : " ^17.1.0 " ,
110
+ "ipfs-api" : " ^17.1.1 " ,
110
111
"ipfs-bitswap" : " ~0.17.4" ,
111
112
"ipfs-block" : " ~0.6.1" ,
112
113
"ipfs-block-service" : " ~0.13.0" ,
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const EventEmitter = require ( 'events' )
4
+
5
+ function fail ( ) {
6
+ throw new Error ( 'The daemon must be run with \'--enable-pubsub-experiment\'' )
7
+ }
8
+
9
+ class NoFloodSub extends EventEmitter {
10
+ constructor ( ) {
11
+ super ( )
12
+
13
+ this . peers = new Map ( )
14
+ this . subscriptions = new Set ( )
15
+ }
16
+
17
+ start ( callback ) { callback ( ) }
18
+ stop ( callback ) { callback ( ) }
19
+ publish ( ) { fail ( ) }
20
+ subscribe ( ) { fail ( ) }
21
+ unsubscribe ( ) { fail ( ) }
22
+ }
23
+
24
+ module . exports = NoFloodSub
Original file line number Diff line number Diff line change 3
3
const series = require ( 'async/series' )
4
4
const Bitswap = require ( 'ipfs-bitswap' )
5
5
const FloodSub = require ( 'libp2p-floodsub' )
6
+ const NoFloodSub = require ( './no-floodsub' )
6
7
const setImmediate = require ( 'async/setImmediate' )
7
8
const promisify = require ( 'promisify-es6' )
8
9
@@ -50,12 +51,10 @@ module.exports = (self) => {
50
51
self . _bitswap . start ( )
51
52
self . _blockService . setExchange ( self . _bitswap )
52
53
53
- if ( self . _options . EXPERIMENTAL . pubsub ) {
54
- self . _pubsub = new FloodSub ( self . _libp2pNode )
55
- self . _pubsub . start ( done )
56
- } else {
57
- done ( )
58
- }
54
+ self . _pubsub = self . _options . EXPERIMENTAL . pubsub
55
+ ? new FloodSub ( self . _libp2pNode )
56
+ : new NoFloodSub ( )
57
+ self . _pubsub . start ( done )
59
58
} )
60
59
} )
61
60
}
Original file line number Diff line number Diff line change @@ -31,13 +31,7 @@ module.exports = (self) => {
31
31
self . _bitswap . stop ( )
32
32
33
33
series ( [
34
- ( cb ) => {
35
- if ( self . _options . EXPERIMENTAL . pubsub ) {
36
- self . _pubsub . stop ( cb )
37
- } else {
38
- cb ( )
39
- }
40
- } ,
34
+ ( cb ) => self . _pubsub . stop ( cb ) ,
41
35
( cb ) => self . libp2p . stop ( cb ) ,
42
36
( cb ) => self . _repo . close ( cb )
43
37
] , done )
Original file line number Diff line number Diff line change 2
2
3
3
const PassThrough = require ( 'stream' ) . PassThrough
4
4
const bs58 = require ( 'bs58' )
5
+ const binaryQueryString = require ( 'binary-querystring' )
5
6
6
7
exports = module . exports
7
8
@@ -48,6 +49,7 @@ exports.subscribe = {
48
49
49
50
reply ( res )
50
51
. header ( 'X-Chunked-Output' , '1' )
52
+ . header ( 'content-encoding' , 'identity' ) // stop gzip from buffering, see https://github.com/hapijs/hapi/issues/2975
51
53
. header ( 'content-type' , 'application/json' )
52
54
} )
53
55
}
@@ -57,7 +59,9 @@ exports.publish = {
57
59
handler : ( request , reply ) => {
58
60
const arg = request . query . arg
59
61
const topic = arg [ 0 ]
60
- const buf = arg [ 1 ]
62
+
63
+ const rawArgs = binaryQueryString ( request . url . search )
64
+ const buf = rawArgs . arg && rawArgs . arg [ 1 ]
61
65
62
66
const ipfs = request . server . app . ipfs
63
67
@@ -69,7 +73,7 @@ exports.publish = {
69
73
return reply ( new Error ( 'Missing buf' ) )
70
74
}
71
75
72
- ipfs . pubsub . publish ( topic , Buffer . from ( String ( buf ) ) , ( err ) => {
76
+ ipfs . pubsub . publish ( topic , buf , ( err ) => {
73
77
if ( err ) {
74
78
return reply ( new Error ( `Failed to publish to topic ${ topic } : ${ err } ` ) )
75
79
}
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ const createTempNode = ''
14
14
const repoPath = require ( './index' ) . repoPath
15
15
const ipfs = require ( '../utils/ipfs-exec' ) ( repoPath )
16
16
17
- describe . skip ( 'pubsub' , ( ) => {
17
+ describe ( 'pubsub' , ( ) => {
18
18
const topicA = 'nonscentsA'
19
19
const topicB = 'nonscentsB'
20
20
const topicC = 'nonscentsC'
Original file line number Diff line number Diff line change 1
- 6
1
+ 6
Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ describe('HTTP API', () => {
19
19
let http = { }
20
20
21
21
before ( ( done ) => {
22
- http . api = new API ( repoTests )
22
+ const options = {
23
+ enablePubsubExperiment : true
24
+ }
25
+ http . api = new API ( repoTests , null , options )
23
26
24
27
ncp ( repoExample , repoTests , ( err ) => {
25
28
expect ( err ) . to . not . exist ( )
Original file line number Diff line number Diff line change 2
2
3
3
'use strict'
4
4
5
- // TODO needs: https://github.com/ipfs/js-ipfs-api/pull/493
6
- /*
7
5
const test = require ( 'interface-ipfs-core' )
8
6
const FactoryClient = require ( './../../utils/ipfs-factory-daemon' )
9
7
@@ -20,4 +18,3 @@ const common = {
20
18
}
21
19
22
20
test . pubsub ( common )
23
- */
Original file line number Diff line number Diff line change @@ -6,35 +6,17 @@ const chai = require('chai')
6
6
const dirtyChai = require ( 'dirty-chai' )
7
7
const expect = chai . expect
8
8
chai . use ( dirtyChai )
9
- const createTempNode = ''
10
9
11
- // TODO migrate to use ipfs-factory-daemon
12
10
module . exports = ( http ) => {
13
- describe . skip ( '/pubsub' , ( ) => {
11
+ describe ( '/pubsub' , ( ) => {
14
12
let api
15
- let tmpNode
16
13
17
14
const buf = Buffer . from ( 'some message' )
18
15
const topic = 'nonScents'
19
16
const topicNotSubscribed = 'somethingRandom'
20
17
21
- before ( ( done ) => {
18
+ before ( ( ) => {
22
19
api = http . api . server . select ( 'API' )
23
-
24
- createTempNode ( 47 , ( err , _ipfs ) => {
25
- expect ( err ) . to . not . exist ( )
26
- tmpNode = _ipfs
27
- tmpNode . goOnline ( ( err ) => {
28
- expect ( err ) . to . not . exist ( )
29
- done ( )
30
- } )
31
- } )
32
- } )
33
-
34
- after ( ( done ) => {
35
- setTimeout ( ( ) => {
36
- tmpNode . goOffline ( done )
37
- } , 1000 )
38
20
} )
39
21
40
22
describe ( '/sub' , ( ) => {
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ require('./exchange-files')
6
6
require ( './circuit-relay' )
7
7
require ( './kad-dht' )
8
8
require ( './pubsub' )
9
+ require ( './pubsub-go' )
You can’t perform that action at this time.
0 commit comments