mining: remove mod size from priority. better free calculation.

This commit is contained in:
Christopher Jeffrey 2017-02-27 16:50:44 -08:00
parent e577228944
commit e31ddaa61a
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 12 additions and 5 deletions

View File

@ -823,7 +823,7 @@ Mempool.prototype.verify = co(function* verify(entry, view) {
} }
// Make sure this guy gave a decent fee. // Make sure this guy gave a decent fee.
minFee = tx.getMinFee(entry.size, this.options.minRelay); minFee = policy.getMinFee(entry.size, this.options.minRelay);
if (this.options.relayPriority && entry.fee < minFee) { if (this.options.relayPriority && entry.fee < minFee) {
if (!entry.isFree(height)) { if (!entry.isFree(height)) {

View File

@ -139,8 +139,7 @@ MempoolEntry.fromTX = function fromTX(tx, view, height) {
MempoolEntry.prototype.getPriority = function getPriority(height) { MempoolEntry.prototype.getPriority = function getPriority(height) {
var heightDelta = height - this.height; var heightDelta = height - this.height;
var modSize = this.tx.getModifiedSize(this.size); var deltaPriority = (heightDelta * this.value) / this.size;
var deltaPriority = (heightDelta * this.value) / modSize;
var result = this.priority + Math.floor(deltaPriority); var result = this.priority + Math.floor(deltaPriority);
if (result < 0) if (result < 0)
result = 0; result = 0;

View File

@ -630,6 +630,8 @@ MinerOptions.fromOptions = function fromOptions(options) {
*/ */
function cmpPriority(a, b) { function cmpPriority(a, b) {
if (a.priority === b.priority)
return cmpRate(a, b);
return b.priority - a.priority; return b.priority - a.priority;
} }
@ -643,6 +645,11 @@ function cmpRate(a, b) {
if (b.descRate > b.rate) if (b.descRate > b.rate)
y = b.descRate; y = b.descRate;
if (x === y) {
x = a.priority;
y = b.priority;
}
return y - x; return y - x;
} }

View File

@ -21,6 +21,7 @@ var Output = require('../primitives/output');
var mine = require('./mine'); var mine = require('./mine');
var workerPool = require('../workers/workerpool').pool; var workerPool = require('../workers/workerpool').pool;
var consensus = require('../protocol/consensus'); var consensus = require('../protocol/consensus');
var policy = require('../protocol/policy');
var encoding = require('../utils/encoding'); var encoding = require('../utils/encoding');
/** /**
@ -584,8 +585,8 @@ function BlockEntry(tx) {
this.priority = 0; this.priority = 0;
this.free = false; this.free = false;
this.sigops = 0; this.sigops = 0;
this.depCount = 0;
this.descRate = 0; this.descRate = 0;
this.depCount = 0;
} }
/** /**
@ -619,7 +620,7 @@ BlockEntry.fromEntry = function fromEntry(entry, attempt) {
item.fee = entry.getFee(); item.fee = entry.getFee();
item.rate = entry.getRate(); item.rate = entry.getRate();
item.priority = entry.getPriority(attempt.height); item.priority = entry.getPriority(attempt.height);
item.free = entry.isFree(attempt.height); item.free = item.fee < policy.getMinFee(entry.size);
item.sigops = entry.sigops; item.sigops = entry.sigops;
item.descRate = entry.getDescRate(); item.descRate = entry.getDescRate();
return item; return item;