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