fix locator hashes by height.
This commit is contained in:
parent
7cabdcfda5
commit
0bd4d798a9
@ -499,22 +499,26 @@ Chain.prototype.getStartHeight = function getStartHeight() {
|
||||
return this.index.heights[this.index.heights.length - 1];
|
||||
};
|
||||
|
||||
Chain.prototype.locatorHashes = function(index) {
|
||||
Chain.prototype.locatorHashes = function(start) {
|
||||
var chain = this.index.hashes;
|
||||
var hashes = [];
|
||||
var top = chain.length - 1;
|
||||
var step = 1;
|
||||
var i;
|
||||
|
||||
if (typeof index === 'string') {
|
||||
if (typeof start === 'string') {
|
||||
// Hash
|
||||
for (i = top; i >= 0; i--) {
|
||||
if (chain[i] === index) {
|
||||
if (chain[i] === start) {
|
||||
top = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (typeof index === 'number') {
|
||||
top = index;
|
||||
} else if (typeof start === 'number') {
|
||||
// Height
|
||||
start = this.index.heights.indexOf(start);
|
||||
if (start !== -1)
|
||||
top = start;
|
||||
}
|
||||
|
||||
i = top;
|
||||
@ -540,14 +544,14 @@ Chain.prototype.getOrphanRoot = function getOrphanRoot(hash) {
|
||||
else if (hash.hash)
|
||||
hash = hash.hash('hex');
|
||||
|
||||
var orphanRoot = hash;
|
||||
var root = hash;
|
||||
|
||||
while (this.orphan.bmap[hash]) {
|
||||
orphanRoot = hash;
|
||||
root = hash;
|
||||
hash = this.orphan.bmap[hash].prevBlock;
|
||||
}
|
||||
|
||||
return orphanRoot;
|
||||
return root;
|
||||
};
|
||||
|
||||
Chain.prototype.toJSON = function toJSON() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user