fix callback order.

This commit is contained in:
Christopher Jeffrey 2014-09-17 14:25:19 -07:00
parent 7f7ef196f4
commit a9d124c058
1 changed files with 11 additions and 11 deletions

View File

@ -35,17 +35,6 @@ Bitcoin.prototype.start = function(callback) {
var errorCaught = none;
this.log_pipe = bitcoindjs.start(function(err, status) {
if (callback) {
callback(err);
callback = null;
}
if (err) {
self.emit('error', err);
} else {
self.emit('open', status);
}
process.on('SIGINT', self.stop.bind(self));
process.on('SIGHUP', self.stop.bind(self));
@ -69,6 +58,17 @@ Bitcoin.prototype.start = function(callback) {
}
self.stop();
});
if (callback) {
callback(err);
callback = null;
}
if (err) {
self.emit('error', err);
} else {
self.emit('open', status);
}
});
// bitcoind's boost threads aren't in the thread pool