remove getHashRange.
This commit is contained in:
parent
9301cf89a2
commit
2b2598a892
@ -1855,52 +1855,6 @@ Chain.prototype.getProgress = function getProgress() {
|
|||||||
return Math.min(1, current / end);
|
return Math.min(1, current / end);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Collect block hashes between a range of two timestamps.
|
|
||||||
* @param {Number} start - Start time (unix time).
|
|
||||||
* @param {Number} end - End time (unix time).
|
|
||||||
* @param {Function} callback - Returns [Error, Hash[]].
|
|
||||||
*/
|
|
||||||
|
|
||||||
Chain.prototype.getHashRange = function getHashRange(start, end, callback) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.byTime(start, function(err, start) {
|
|
||||||
if (err)
|
|
||||||
return callback(err);
|
|
||||||
|
|
||||||
self.byTime(end, function(err, end) {
|
|
||||||
var hashes;
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
return callback(err);
|
|
||||||
|
|
||||||
hashes = [];
|
|
||||||
|
|
||||||
if (!start || !end)
|
|
||||||
return callback(null, hashes);
|
|
||||||
|
|
||||||
utils.forRangeSerial(start.height, end.height + 1, function(i, next) {
|
|
||||||
self.db.getHash(i, function(err, hash) {
|
|
||||||
if (err)
|
|
||||||
return next(err);
|
|
||||||
|
|
||||||
if (!hash)
|
|
||||||
return next(new Error('No entry for hash range.'));
|
|
||||||
|
|
||||||
hashes.push(hash);
|
|
||||||
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
}, function(err) {
|
|
||||||
if (err)
|
|
||||||
return callback(err);
|
|
||||||
return callback(null, hashes);
|
|
||||||
});
|
|
||||||
}, true);
|
|
||||||
}, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate chain locator (an array of hashes).
|
* Calculate chain locator (an array of hashes).
|
||||||
* @param {(Number|Hash)?} start - Height or hash to treat as the tip.
|
* @param {(Number|Hash)?} start - Height or hash to treat as the tip.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user