chain: remove chain.byTime.

This commit is contained in:
Christopher Jeffrey 2017-01-14 06:44:00 -08:00
parent fd2f158169
commit 07414f5fd3
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1621,44 +1621,6 @@ Chain.prototype.seen = function seen(hash) {
return this.db.hasCache(hash);
};
/**
* Find a block entry by timestamp.
* @param {Number} ts - Timestamp.
* @returns {Promise} - Returns {@link ChainEntry}.
*/
Chain.prototype.byTime = co(function* byTime(ts) {
var start = 0;
var end = this.height;
var pos, delta, entry;
if (ts >= this.tip.ts)
return this.tip;
// Do a binary search for a block
// mined within an hour of the
// timestamp.
while (start < end) {
pos = (start + end) >>> 1;
entry = yield this.db.getEntry(pos);
if (!entry)
return;
delta = Math.abs(ts - entry.ts);
if (delta <= 60 * 60)
break;
if (ts < entry.ts)
end = pos - 1;
else
start = pos + 1;
}
return entry;
});
/**
* Test the chain to see if it contains a block.
* @param {Hash} hash