mempool.
This commit is contained in:
parent
fc6feb2125
commit
b088d3fb44
@ -170,6 +170,8 @@ Fullnode.prototype._init = function _init() {
|
||||
});
|
||||
|
||||
this.chain.on('add block', function(block) {
|
||||
if (!self.chain.isFull())
|
||||
return;
|
||||
self.mempool.addBlock(block, function(err) {
|
||||
if (err)
|
||||
self.emit('error', err);
|
||||
@ -177,11 +179,15 @@ Fullnode.prototype._init = function _init() {
|
||||
});
|
||||
|
||||
this.chain.on('remove block', function(block) {
|
||||
self.mempool.removeBlock(block, function(err) {
|
||||
self.walletdb.removeBlock(block, function(err) {
|
||||
if (err)
|
||||
self.emit('error', err);
|
||||
});
|
||||
self.walletdb.removeBlock(block, function(err) {
|
||||
|
||||
if (!self.chain.isFull())
|
||||
return;
|
||||
|
||||
self.mempool.removeBlock(block, function(err) {
|
||||
if (err)
|
||||
self.emit('error', err);
|
||||
});
|
||||
|
||||
@ -229,7 +229,8 @@ Mempool.prototype.addBlock = function addBlock(block, callback, force) {
|
||||
callback = utils.wrap(callback, unlock);
|
||||
entries = [];
|
||||
|
||||
utils.forEachSerial(block.txs.slice().reverse(), function(tx, next) {
|
||||
utils.forRangeSerial(0, block.txs.length, function(i, next) {
|
||||
var tx = block.txs[block.txs.length - 1 - i];
|
||||
var hash = tx.hash('hex');
|
||||
|
||||
if (tx.isCoinbase())
|
||||
@ -287,10 +288,12 @@ Mempool.prototype.removeBlock = function removeBlock(block, callback, force) {
|
||||
callback = utils.wrap(callback, unlock);
|
||||
|
||||
utils.forEachSerial(block.txs, function(tx, next) {
|
||||
var hash = tx.hash('hex');
|
||||
|
||||
if (tx.isCoinbase())
|
||||
return next();
|
||||
|
||||
self.hasTX(tx.hash('hex'), function(err, result) {
|
||||
self.hasTX(hash, function(err, result) {
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
@ -902,7 +905,7 @@ Mempool.prototype.addUnchecked = function addUnchecked(entry, callback, force) {
|
||||
|
||||
Mempool.prototype.removeUnchecked = function removeUnchecked(entry, limit, callback, force) {
|
||||
var self = this;
|
||||
var unlock, rate;
|
||||
var unlock, rate, hash;
|
||||
|
||||
unlock = this._lock(removeUnchecked, [entry, limit, callback], force);
|
||||
|
||||
@ -911,6 +914,8 @@ Mempool.prototype.removeUnchecked = function removeUnchecked(entry, limit, callb
|
||||
|
||||
callback = utils.wrap(callback, unlock);
|
||||
|
||||
hash = entry.tx.hash('hex');
|
||||
|
||||
this.fillAllHistory(entry.tx, function(err) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
@ -925,10 +930,10 @@ Mempool.prototype.removeUnchecked = function removeUnchecked(entry, limit, callb
|
||||
self.size -= self.memUsage(entry.tx);
|
||||
self.total--;
|
||||
|
||||
self.network.fees.removeTX(entry.tx.hash('hex'));
|
||||
self.network.fees.removeTX(hash);
|
||||
|
||||
if (limit) {
|
||||
rate = bcoin.tx.getRate(entry.size, entry.fees);
|
||||
rate = bcoin.tx.getRate(entry.sizes, entry.fees);
|
||||
rate += self.minReasonableFee;
|
||||
if (rate > self.minFeeRate) {
|
||||
self.minFeeRate = rate;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user