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

Commit 9b1aea7

Browse files
committed
fix: let protocols initiate properly
1 parent 50ae06d commit 9b1aea7

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/core/components/go-online.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const FloodSub = require('libp2p-floodsub')
77
module.exports = (self) => {
88
return (callback) => {
99
series([
10-
self.load,
11-
self.libp2p.start
10+
(cb) => self.load(cb),
11+
(cb) => self.libp2p.start(cb)
1212
], (err) => {
1313
if (err) {
1414
return callback(err)
@@ -19,12 +19,22 @@ module.exports = (self) => {
1919
self._repo.blockstore,
2020
self._libp2pNode.peerBook
2121
)
22-
self._bitswap.start()
23-
24-
self._blockService.goOnline(self._bitswap)
2522

2623
self._pubsub = new FloodSub(self._libp2pNode)
27-
self._pubsub.start(callback)
24+
25+
series([
26+
(cb) => {
27+
self._bitswap.start()
28+
cb()
29+
},
30+
(cb) => {
31+
self._blockService.goOnline(self._bitswap)
32+
cb()
33+
},
34+
(cb) => self._pubsub.start(cb),
35+
// For all of the protocols to handshake with each other
36+
(cb) => setTimeout(cb, 1000)
37+
], callback)
2838
})
2939
}
3040
}

0 commit comments

Comments
 (0)