refactor mempool.
This commit is contained in:
parent
88a5b8a784
commit
8f3fae329d
@ -642,11 +642,19 @@ Mempool.prototype.addTX = function addTX(tx, callback, force) {
|
||||
0));
|
||||
}
|
||||
|
||||
if (!tx.isSane(ret))
|
||||
return callback(new VerifyError(tx, 'invalid', ret.reason, ret.score));
|
||||
if (!tx.isSane(ret)) {
|
||||
return callback(new VerifyError(tx,
|
||||
'invalid',
|
||||
ret.reason,
|
||||
ret.score));
|
||||
}
|
||||
|
||||
if (tx.isCoinbase())
|
||||
return callback(new VerifyError(tx, 'invalid', 'coinbase', 100));
|
||||
if (tx.isCoinbase()) {
|
||||
return callback(new VerifyError(tx,
|
||||
'invalid',
|
||||
'coinbase',
|
||||
100));
|
||||
}
|
||||
|
||||
if (this.requireStandard) {
|
||||
if (!tx.isStandard(flags, ret))
|
||||
@ -661,16 +669,24 @@ Mempool.prototype.addTX = function addTX(tx, callback, force) {
|
||||
}
|
||||
|
||||
if (!this.chain.segwitActive && !this.prematureWitness) {
|
||||
if (tx.hasWitness())
|
||||
return callback(new VerifyError(tx, 'nonstandard', 'no-witness-yet', 0));
|
||||
if (tx.hasWitness()) {
|
||||
return callback(new VerifyError(tx,
|
||||
'nonstandard',
|
||||
'no-witness-yet',
|
||||
0));
|
||||
}
|
||||
}
|
||||
|
||||
this.chain.checkFinal(this.chain.tip, tx, lockFlags, function(err, isFinal) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
if (!isFinal)
|
||||
return callback(new VerifyError(tx, 'nonstandard', 'non-final', 0));
|
||||
if (!isFinal) {
|
||||
return callback(new VerifyError(tx,
|
||||
'nonstandard',
|
||||
'non-final',
|
||||
0));
|
||||
}
|
||||
|
||||
self.has(hash, function(err, exists) {
|
||||
if (err)
|
||||
@ -885,10 +901,7 @@ Mempool.prototype.getMinRate = function getMinRate() {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.minFeeRate > this.minReasonableFee)
|
||||
return this.minFeeRate;
|
||||
|
||||
return this.minReasonableFee;
|
||||
return Math.max(this.minFeeRate, this.minReasonableFee);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1853,7 +1866,7 @@ MempoolEntry.prototype.getPriority = function getPriority(height) {
|
||||
var heightDelta = height - this.height;
|
||||
var modSize = this.tx.getModifiedSize(this.size);
|
||||
var deltaPriority = heightDelta * this.chainValue / modSize;
|
||||
var result = this.priority * deltaPriority;
|
||||
var result = this.priority + deltaPriority;
|
||||
if (result < 0)
|
||||
result = 0;
|
||||
return result;
|
||||
@ -1907,10 +1920,11 @@ function mallocUsage(alloc) {
|
||||
return ((alloc + 15) >>> 3) << 3;
|
||||
}
|
||||
|
||||
Mempool.MempoolEntry = MempoolEntry;
|
||||
|
||||
/*
|
||||
* Expose
|
||||
*/
|
||||
|
||||
module.exports = Mempool;
|
||||
exports = Mempool;
|
||||
exports.MempoolEntry = MempoolEntry;
|
||||
|
||||
module.exports = exports;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user