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);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var height, hash;
|
var hash;
|
||||||
//genesis block, set to -1 because we have no yet processed the blocks
|
//genesis block, set to -1 because we have no yet processed the blocks
|
||||||
if (!tipData) {
|
if (!tipData) {
|
||||||
height = -1;
|
|
||||||
hash = new Array(65).join('0');
|
hash = new Array(65).join('0');
|
||||||
self[tip] = {
|
self[tip] = {
|
||||||
height: height,
|
height: -1,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
'__height': height
|
'__height': -1
|
||||||
};
|
};
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
height = tipData.readUInt32BE(32);
|
|
||||||
hash = tipData.slice(0, 32).toString('hex');
|
hash = tipData.slice(0, 32).toString('hex');
|
||||||
|
|
||||||
self.bitcoind.getBlock(hash, function(err, block) {
|
self.bitcoind.getBlock(hash, function(err, block) {
|
||||||
@ -321,10 +319,18 @@ DB.prototype.loadTips = function(callback) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
block.__height = height;
|
self.bitcoind.getBlockHeader(hash, function(err, header) {
|
||||||
self[tip] = block;
|
|
||||||
next();
|
|
||||||
|
|
||||||
|
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