From 07414f5fd3fe27b892d412bf61ca01f4268a9a6d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 14 Jan 2017 06:44:00 -0800 Subject: [PATCH] chain: remove chain.byTime. --- lib/blockchain/chain.js | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index d3a57f00..96666f8e 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -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