miner: improve policy defaults. switch rate sorting immediately.
This commit is contained in:
parent
3ec781ee60
commit
dcf7e7a9f4
@ -368,11 +368,14 @@ Miner.prototype.getAddress = function getAddress() {
|
|||||||
Miner.prototype.build = function build(attempt) {
|
Miner.prototype.build = function build(attempt) {
|
||||||
var depMap = {};
|
var depMap = {};
|
||||||
var block = attempt.block;
|
var block = attempt.block;
|
||||||
var queue = new Queue(cmpPriority);
|
var queue = new Queue(cmpRate);
|
||||||
var priority = true;
|
var priority = this.priorityWeight > 0;
|
||||||
var i, j, entry, item, tx, hash, input;
|
var i, j, entry, item, tx, hash, input;
|
||||||
var prev, deps, hashes, weight, sigops;
|
var prev, deps, hashes, weight, sigops;
|
||||||
|
|
||||||
|
if (priority)
|
||||||
|
queue.sort(cmpPriority);
|
||||||
|
|
||||||
if (!this.mempool)
|
if (!this.mempool)
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
@ -433,10 +436,10 @@ Miner.prototype.build = function build(attempt) {
|
|||||||
|
|
||||||
if (priority) {
|
if (priority) {
|
||||||
if (weight > this.options.priorityWeight
|
if (weight > this.options.priorityWeight
|
||||||
|| item.priority < this.options.minPriority) {
|
|| item.priority < this.options.priorityThreshold) {
|
||||||
// Todo: Compare descendant rate with
|
// Todo: Compare descendant rate with
|
||||||
// cumulative fees and cumulative vsize.
|
// cumulative fees and cumulative vsize.
|
||||||
queue.cmp = cmpRate;
|
queue.sort(cmpRate);
|
||||||
priority = false;
|
priority = false;
|
||||||
queue.push(item);
|
queue.push(item);
|
||||||
continue;
|
continue;
|
||||||
@ -495,8 +498,8 @@ function MinerOptions(options) {
|
|||||||
|
|
||||||
this.minWeight = policy.MIN_BLOCK_WEIGHT;
|
this.minWeight = policy.MIN_BLOCK_WEIGHT;
|
||||||
this.maxWeight = policy.MAX_BLOCK_WEIGHT;
|
this.maxWeight = policy.MAX_BLOCK_WEIGHT;
|
||||||
this.priorityWeight = policy.PRIORITY_BLOCK_WEIGHT;
|
this.priorityWeight = policy.BLOCK_PRIORITY_WEIGHT;
|
||||||
this.minPriority = policy.MIN_BLOCK_PRIORITY;
|
this.priorityThreshold = policy.BLOCK_PRIORITY_THRESHOLD;
|
||||||
this.maxSigops = consensus.MAX_BLOCK_SIGOPS_COST;
|
this.maxSigops = consensus.MAX_BLOCK_SIGOPS_COST;
|
||||||
this.reservedWeight = 4000;
|
this.reservedWeight = 4000;
|
||||||
this.reservedSigops = 400;
|
this.reservedSigops = 400;
|
||||||
@ -585,9 +588,9 @@ MinerOptions.prototype.fromOptions = function fromOptions(options) {
|
|||||||
this.priorityWeight = options.priorityWeight;
|
this.priorityWeight = options.priorityWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.minPriority != null) {
|
if (options.priorityThreshold != null) {
|
||||||
assert(util.isNumber(options.minPriority));
|
assert(util.isNumber(options.priorityThreshold));
|
||||||
this.minPriority = options.minPriority;
|
this.priorityThreshold = options.priorityThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.reservedWeight != null) {
|
if (options.reservedWeight != null) {
|
||||||
@ -620,7 +623,7 @@ MinerOptions.fromOptions = function fromOptions(options) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function Queue(cmp) {
|
function Queue(cmp) {
|
||||||
this.cmp = cmp;
|
this.cmp = cmp || null;
|
||||||
this.items = [];
|
this.items = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,6 +632,7 @@ Queue.prototype.size = function size() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Queue.prototype.push = function push(item) {
|
Queue.prototype.push = function push(item) {
|
||||||
|
assert(this.cmp, 'No comparator for queue.');
|
||||||
util.binaryInsert(this.items, item, this.cmp);
|
util.binaryInsert(this.items, item, this.cmp);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -636,6 +640,12 @@ Queue.prototype.pop = function pop() {
|
|||||||
return this.items.pop();
|
return this.items.pop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Queue.prototype.sort = function sort(cmp) {
|
||||||
|
assert(cmp === null || typeof cmp === 'function',
|
||||||
|
'Comparator must be a function.');
|
||||||
|
this.cmp = cmp;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helpers
|
* Helpers
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -172,9 +172,9 @@ exports.MEMPOOL_EXPIRY_TIME = 72 * 60 * 60;
|
|||||||
exports.MEMPOOL_MAX_ORPHANS = 100;
|
exports.MEMPOOL_MAX_ORPHANS = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block weight to be reached before
|
* Minimum block size to create. Block will be
|
||||||
* rejecting priority transactions during
|
* filled with free transactions until block
|
||||||
* mining.
|
* reaches this weight.
|
||||||
* @const {Number}
|
* @const {Number}
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
@ -187,26 +187,26 @@ exports.MIN_BLOCK_WEIGHT = 0;
|
|||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.MAX_BLOCK_WEIGHT = 750000 * consensus.WITNESS_SCALE_FACTOR;
|
exports.MAX_BLOCK_WEIGHT = 1000000 * consensus.WITNESS_SCALE_FACTOR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bottom priority threshold to be seen
|
* How much of the block should be dedicated to
|
||||||
* before ignoring priority transactions
|
* high-priority transactions (included regardless
|
||||||
* during mining.
|
* of fee rate).
|
||||||
* @const {Number}
|
* @const {Number}
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.MIN_BLOCK_PRIORITY = 50000 * consensus.WITNESS_SCALE_FACTOR;
|
exports.BLOCK_PRIORITY_WEIGHT = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Weight to be reached before ignoring
|
* Priority threshold to be reached before
|
||||||
* priority transactions during mining.
|
* switching to fee rate comparison.
|
||||||
* @const {Number}
|
* @const {Number}
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.PRIORITY_BLOCK_WEIGHT = exports.FREE_THRESHOLD;
|
exports.BLOCK_PRIORITY_THRESHOLD = exports.FREE_THRESHOLD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate minimum fee based on rate and size.
|
* Calculate minimum fee based on rate and size.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user