Skip to content

Commit bf6ad4e

Browse files
committed
refactor(Node): call 'start' callback before chain without waiting for chain sync
We were previously waiting until the chain was all the way synced, which can take a while.
1 parent f432f5b commit bf6ad4e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/node.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ var Node = module.exports = function (opts, cb) {
4646
util.inherits(Node, EventEmitter)
4747

4848
Node.prototype.start = function (cb) {
49+
var self = this
4950
cb = cb || function () {}
5051

5152
this.peers.on('peerconnect', this._onPeerConnect.bind(this))
5253

5354
async.parallel([
5455
this.peers.connect.bind(this.peers),
55-
this.chain.sync.bind(this.chain)
56+
function (cb) {
57+
self.chain.on('syncing', function () { cb(null) })
58+
self.chain.sync()
59+
}
5660
], cb)
5761

5862
this.emit('ready')

0 commit comments

Comments
 (0)