Height not properly set during reorg situation. Fixed.
This commit is contained in:
parent
c080a62958
commit
61e5d77fea
@ -299,20 +299,18 @@ DB.prototype.loadTips = function(callback) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
var height, hash;
|
||||
var hash;
|
||||
//genesis block, set to -1 because we have no yet processed the blocks
|
||||
if (!tipData) {
|
||||
height = -1;
|
||||
hash = new Array(65).join('0');
|
||||
self[tip] = {
|
||||
height: height,
|
||||
height: -1,
|
||||
hash: hash,
|
||||
'__height': height
|
||||
'__height': -1
|
||||
};
|
||||
return next();
|
||||
}
|
||||
|
||||
height = tipData.readUInt32BE(32);
|
||||
hash = tipData.slice(0, 32).toString('hex');
|
||||
|
||||
self.bitcoind.getBlock(hash, function(err, block) {
|
||||
@ -321,10 +319,18 @@ DB.prototype.loadTips = function(callback) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
block.__height = height;
|
||||
self[tip] = block;
|
||||
next();
|
||||
self.bitcoind.getBlockHeader(hash, function(err, header) {
|
||||
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
block.__height = header.height;
|
||||
self[tip] = block;
|
||||
log.info('loaded tip, hash: ' + block.hash + ' height: ' + block.__height);
|
||||
next();
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user