From f0cc8eb128523017b131c378ed004ca0ec7d516c Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 14 May 2017 22:11:52 -0700 Subject: [PATCH] chain: rename some methods. remove unused methods. --- lib/blockchain/chain.js | 39 ++------------------------------------- lib/blockchain/chaindb.js | 6 +++--- 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 28173741..c7fb7fd2 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -1142,10 +1142,10 @@ Chain.prototype._invalidate = co(function* _invalidate(hash) { * @returns {Promise} */ -Chain.prototype.retroPrune = co(function* retroPrune() { +Chain.prototype.prune = co(function* prune() { var unlock = yield this.locker.lock(); try { - return yield this.db.retroPrune(this.tip.hash); + return yield this.db.prune(this.tip.hash); } finally { unlock(); } @@ -1169,41 +1169,6 @@ Chain.prototype.scan = co(function* scan(start, filter, iter) { } }); -/** - * Reset the chain to the desired timestamp (within 2 - * hours). This is useful for replaying the blockchain - * download for SPV. - * @method - * @param {Number} ts - Timestamp. - * @returns {Promise} - */ - -Chain.prototype.resetTime = co(function* resetTime(ts) { - var unlock = yield this.locker.lock(); - try { - return yield this._resetTime(ts); - } finally { - unlock(); - } -}); - -/** - * Reset the chain to the desired timestamp without a lock. - * @private - * @method - * @param {Number} ts - Timestamp. - * @returns {Promise} - */ - -Chain.prototype._resetTime = co(function* resetTime(ts) { - var entry = yield this.byTime(ts); - - if (!entry) - return; - - yield this._reset(entry.height, false); -}); - /** * Add a block to the chain, perform all necessary verification. * @method diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index ee68e6a2..02a2af98 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -548,7 +548,7 @@ ChainDB.prototype.verifyFlags = co(function* verifyFlags(state) { if (needsPrune) { yield this.logger.info('Retroactively pruning chain.'); - yield this.retroPrune(state.hash()); + yield this.prune(state.hash()); } }); @@ -706,7 +706,7 @@ ChainDB.prototype.invalidateCache = co(function* invalidateCache(bit, batch) { * @returns {Promise} */ -ChainDB.prototype.retroPrune = co(function* retroPrune(tip) { +ChainDB.prototype.prune = co(function* prune(tip) { var options = this.options; var keepBlocks = this.network.block.keepBlocks; var pruneAfter = this.network.block.pruneAfterHeight; @@ -715,7 +715,7 @@ ChainDB.prototype.retroPrune = co(function* retroPrune(tip) { var i, start, end, batch, hash; if (flags.prune) - throw new Error('Already pruned.'); + throw new Error('Chain is already pruned.'); if (height <= pruneAfter + keepBlocks) return false;