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