add txs to mempool before removing.
This commit is contained in:
parent
2b2598a892
commit
5d1e3e1034
@ -205,36 +205,72 @@ Mempool.prototype.addBlock = function addBlock(block, callback, force) {
|
|||||||
|
|
||||||
callback = utils.wrap(callback, unlock);
|
callback = utils.wrap(callback, unlock);
|
||||||
|
|
||||||
utils.forEachSerial(block.txs, function(tx, next) {
|
// We add the txs we haven't seen to
|
||||||
var hash = tx.hash('hex');
|
// the mempool first to potentially
|
||||||
var copy;
|
// resolve orphans.
|
||||||
|
utils.forEachSerial(block.txs, function(tx, next) {
|
||||||
|
var hash, copy;
|
||||||
|
|
||||||
|
if (!self.chain.isFull())
|
||||||
|
return next();
|
||||||
|
|
||||||
if (tx.isCoinbase())
|
if (tx.isCoinbase())
|
||||||
return next();
|
return next();
|
||||||
|
|
||||||
self.getTX(hash, function(err, existing) {
|
hash = tx.hash('hex');
|
||||||
|
|
||||||
|
self.hasTX(hash, function(err, exists) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return next(err);
|
||||||
|
|
||||||
if (!existing)
|
if (exists)
|
||||||
return self.removeOrphan(hash, next);
|
return next();
|
||||||
|
|
||||||
copy = tx.clone();
|
self.removeOrphan(hash, function(err) {
|
||||||
copy.ts = existing.ts;
|
|
||||||
copy.block = existing.block;
|
|
||||||
copy.height = existing.height;
|
|
||||||
copy.ps = existing.ps;
|
|
||||||
|
|
||||||
self.removeUnchecked(copy, function(err) {
|
|
||||||
if (err)
|
if (err)
|
||||||
return next(err);
|
return next(err);
|
||||||
|
|
||||||
self.emit('confirmed', tx, block);
|
copy = tx.clone();
|
||||||
|
copy.unsetBlock();
|
||||||
|
|
||||||
return next();
|
self.addUnchecked(tx, next);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, callback);
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
|
|
||||||
|
utils.forEachSerial(block.txs.slice().reverse(), function(tx, next) {
|
||||||
|
var hash = tx.hash('hex');
|
||||||
|
var copy;
|
||||||
|
|
||||||
|
if (tx.isCoinbase())
|
||||||
|
return next();
|
||||||
|
|
||||||
|
self.getTX(hash, function(err, existing) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
|
if (!existing)
|
||||||
|
return self.removeOrphan(hash, next);
|
||||||
|
|
||||||
|
copy = tx.clone();
|
||||||
|
copy.ts = existing.ts;
|
||||||
|
copy.block = existing.block;
|
||||||
|
copy.height = existing.height;
|
||||||
|
copy.ps = existing.ps;
|
||||||
|
|
||||||
|
self.removeUnchecked(copy, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
|
self.emit('confirmed', tx, block);
|
||||||
|
|
||||||
|
return next();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, callback);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,7 +289,7 @@ Mempool.prototype.removeBlock = function removeBlock(block, callback, force) {
|
|||||||
|
|
||||||
callback = utils.wrap(callback, unlock);
|
callback = utils.wrap(callback, unlock);
|
||||||
|
|
||||||
utils.forEachSerial(block.txs.slice().reverse(), function(tx, next) {
|
utils.forEachSerial(block.txs, function(tx, next) {
|
||||||
var copy;
|
var copy;
|
||||||
|
|
||||||
if (tx.isCoinbase())
|
if (tx.isCoinbase())
|
||||||
|
|||||||
@ -509,7 +509,7 @@ testnet.block = {
|
|||||||
pruneAfterHeight: 1000,
|
pruneAfterHeight: 1000,
|
||||||
// maxTipAge: 0x7fffffff
|
// maxTipAge: 0x7fffffff
|
||||||
maxTipAge: 24 * 60 * 60,
|
maxTipAge: 24 * 60 * 60,
|
||||||
slowHeight: 500000
|
slowHeight: 750000
|
||||||
};
|
};
|
||||||
|
|
||||||
testnet.witness = false;
|
testnet.witness = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user