chain: drop spv reorganization for now.
This commit is contained in:
parent
51e3228d83
commit
42cc8c4698
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user