fix reorganize.
This commit is contained in:
parent
5b1ce02324
commit
1839bb5725
@ -1002,20 +1002,18 @@ Chain.prototype._reorganize = function _reorganize(entry, block, callback) {
|
|||||||
function disconnect(callback) {
|
function disconnect(callback) {
|
||||||
var entries = [];
|
var entries = [];
|
||||||
|
|
||||||
entries.push(tip);
|
|
||||||
|
|
||||||
(function collect(entry) {
|
(function collect(entry) {
|
||||||
|
if (entry.hash === fork.hash)
|
||||||
|
return finish();
|
||||||
|
|
||||||
|
entries.push(entry);
|
||||||
|
|
||||||
entry.getPrevious(function(err, entry) {
|
entry.getPrevious(function(err, entry) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
||||||
assert(entry);
|
assert(entry);
|
||||||
|
|
||||||
if (entry.hash === fork.hash)
|
|
||||||
return finish();
|
|
||||||
|
|
||||||
entries.push(entry);
|
|
||||||
|
|
||||||
collect(entry);
|
collect(entry);
|
||||||
});
|
});
|
||||||
})(tip);
|
})(tip);
|
||||||
@ -1032,23 +1030,28 @@ Chain.prototype._reorganize = function _reorganize(entry, block, callback) {
|
|||||||
var entries = [];
|
var entries = [];
|
||||||
|
|
||||||
(function collect(entry) {
|
(function collect(entry) {
|
||||||
|
if (entry.hash === fork.hash)
|
||||||
|
return finish();
|
||||||
|
|
||||||
|
entries.push(entry);
|
||||||
|
|
||||||
entry.getPrevious(function(err, entry) {
|
entry.getPrevious(function(err, entry) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
||||||
assert(entry);
|
assert(entry);
|
||||||
|
|
||||||
if (entry.hash === fork.hash)
|
|
||||||
return finish();
|
|
||||||
|
|
||||||
entries.push(entry);
|
|
||||||
|
|
||||||
collect(entry);
|
collect(entry);
|
||||||
});
|
});
|
||||||
})(entry);
|
})(entry);
|
||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
entries = entries.slice().reverse();
|
entries = entries.slice().reverse();
|
||||||
|
|
||||||
|
// We don't want to connect the new tip here.
|
||||||
|
// That will be done outside in setBestChain.
|
||||||
|
entries.pop();
|
||||||
|
|
||||||
utils.forEachSerial(entries, function(entry, next) {
|
utils.forEachSerial(entries, function(entry, next) {
|
||||||
self.connect(entry, next);
|
self.connect(entry, next);
|
||||||
}, callback);
|
}, callback);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user