bitcoind: set height when starting

This commit is contained in:
Braydon Fuller 2016-04-06 11:43:02 -04:00
parent 9409374fbe
commit 5932b34a1f

View File

@ -266,14 +266,22 @@ Bitcoin.prototype.start = function(callback) {
pass: self.configuration.rpcpassword
});
self.client.getInfo(function(err) {
self.client.getBestBlockHash(function(err, response) {
if (err) {
if (!(err instanceof Error)) {
log.warn(err.message);
}
return done(new Error('Could not connect to bitcoind RPC'));
}
done();
self.client.getBlock(response.result, function(err, response) {
if (err) {
return done(err);
}
self.height = response.result.height;
$.checkState(self.height >= 0);
self.emit('tip', self.height);
done();
});
});
}, function ready(err, result) {