miner: rename fill. add comments.
This commit is contained in:
parent
c6eabdb121
commit
4c9d9d5160
@ -54,6 +54,7 @@ function Miner(options) {
|
|||||||
|
|
||||||
this.minWeight = 0;
|
this.minWeight = 0;
|
||||||
this.maxWeight = 750000 * constants.WITNESS_SCALE_FACTOR;
|
this.maxWeight = 750000 * constants.WITNESS_SCALE_FACTOR;
|
||||||
|
this.maxSigops = constants.block.MAX_SIGOPS_WEIGHT;
|
||||||
this.priorityWeight = 50000 * constants.WITNESS_SCALE_FACTOR;
|
this.priorityWeight = 50000 * constants.WITNESS_SCALE_FACTOR;
|
||||||
this.minPriority = constants.tx.FREE_THRESHOLD;
|
this.minPriority = constants.tx.FREE_THRESHOLD;
|
||||||
|
|
||||||
@ -103,6 +104,12 @@ Miner.prototype._initOptions = function _initOptions(options) {
|
|||||||
this.maxWeight = options.maxWeight;
|
this.maxWeight = options.maxWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.maxSigops != null) {
|
||||||
|
assert(utils.isNumber(options.maxSigops));
|
||||||
|
assert(options.maxSigops <= constants.block.MAX_SIGOPS_WEIGHT);
|
||||||
|
this.maxSigops = options.maxSigops;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.priorityWeight != null) {
|
if (options.priorityWeight != null) {
|
||||||
assert(utils.isNumber(options.priorityWeight));
|
assert(utils.isNumber(options.priorityWeight));
|
||||||
this.priorityWeight = options.priorityWeight;
|
this.priorityWeight = options.priorityWeight;
|
||||||
@ -332,7 +339,7 @@ Miner.prototype.createBlock = co(function* createBlock(tip, address) {
|
|||||||
network: this.network
|
network: this.network
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fill(attempt);
|
this.build(attempt);
|
||||||
|
|
||||||
return attempt;
|
return attempt;
|
||||||
});
|
});
|
||||||
@ -387,10 +394,11 @@ Miner.prototype.getAddress = function getAddress() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mempool entries, sort by dependency order.
|
* Get mempool entries, sort by dependency order.
|
||||||
|
* Prioritize by priority and fee rates.
|
||||||
* @returns {MempoolEntry[]}
|
* @returns {MempoolEntry[]}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Miner.prototype.fill = function fill(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(cmpPriority);
|
||||||
@ -456,11 +464,13 @@ Miner.prototype.fill = function fill(attempt) {
|
|||||||
|
|
||||||
sigops += tx.getSigopsWeight(attempt.flags);
|
sigops += tx.getSigopsWeight(attempt.flags);
|
||||||
|
|
||||||
if (sigops > constants.block.MAX_SIGOPS_WEIGHT)
|
if (sigops > this.maxSigops)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (priority) {
|
if (priority) {
|
||||||
if (weight > this.priorityWeight || item.priority < this.minPriority) {
|
if (weight > this.priorityWeight || item.priority < this.minPriority) {
|
||||||
|
// Todo: Compare descendant rate with
|
||||||
|
// cumulative fees and cumulative vsize.
|
||||||
queue.cmp = cmpRate;
|
queue.cmp = cmpRate;
|
||||||
priority = false;
|
priority = false;
|
||||||
queue.push(item);
|
queue.push(item);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user