From 42cc8c4698333d12cc99011e532ad3bdd9298140 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 10 Nov 2016 16:11:53 -0800 Subject: [PATCH] chain: drop spv reorganization for now. --- lib/chain/chain.js | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/lib/chain/chain.js b/lib/chain/chain.js index 19feb01c..2bada043 100644 --- a/lib/chain/chain.js +++ b/lib/chain/chain.js @@ -795,42 +795,6 @@ Chain.prototype.reorganize = co(function* reorganize(competitor, block) { this.emit('reorganize', block, tip.height, tip.hash); }); -/** - * Reorganize the blockchain for SPV. - * @private - * @param {ChainEntry} competitor - The competing chain's tip. - * @param {Block|MerkleBlock} block - The being being added. - * @returns {Promise} - */ - -Chain.prototype.reorganizeSPV = co(function* reorganizeSPV(competitor, block) { - var tip = this.tip; - var fork = yield this.findFork(tip, competitor); - var entry, prev; - - assert(fork); - - // Blocks to disconnect. - entry = tip; - while (entry.hash !== fork.hash) { - this.emit('disconnect', entry, entry.toHeaders()); - entry = yield entry.getPrevious(); - assert(entry); - } - - // We need to remove the alternate - // chain to prevent further reorgs. - prev = yield competitor.getPrevious(); - assert(prev); - yield this.db.removeChain(prev, fork); - - // Reset the main chain back - // to the fork block. - yield this._reset(fork.hash); - - this.emit('reorganize', block, tip.height, tip.hash); -}); - /** * Disconnect an entry from the chain (updates the tip). * @param {ChainEntry} entry @@ -919,12 +883,6 @@ Chain.prototype.setBestChain = co(function* setBestChain(entry, block, prev) { // Time to reorganize the chain. if (entry.prevBlock !== this.tip.hash) { this.logger.warning('WARNING: Reorganizing chain.'); - - // In spv-mode, we reset the - // chain and redownload the blocks. - if (this.options.spv) - return yield this.reorganizeSPV(entry, block); - yield this.reorganize(entry, block); }