miner: rename fill. add comments.

This commit is contained in:
Christopher Jeffrey 2016-11-18 23:48:01 -08:00
parent c6eabdb121
commit 4c9d9d5160
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -54,6 +54,7 @@ function Miner(options) {
this.minWeight = 0;
this.maxWeight = 750000 * constants.WITNESS_SCALE_FACTOR;
this.maxSigops = constants.block.MAX_SIGOPS_WEIGHT;
this.priorityWeight = 50000 * constants.WITNESS_SCALE_FACTOR;
this.minPriority = constants.tx.FREE_THRESHOLD;
@ -103,6 +104,12 @@ Miner.prototype._initOptions = function _initOptions(options) {
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) {
assert(utils.isNumber(options.priorityWeight));
this.priorityWeight = options.priorityWeight;
@ -332,7 +339,7 @@ Miner.prototype.createBlock = co(function* createBlock(tip, address) {
network: this.network
});
this.fill(attempt);
this.build(attempt);
return attempt;
});
@ -387,10 +394,11 @@ Miner.prototype.getAddress = function getAddress() {
/**
* Get mempool entries, sort by dependency order.
* Prioritize by priority and fee rates.
* @returns {MempoolEntry[]}
*/
Miner.prototype.fill = function fill(attempt) {
Miner.prototype.build = function build(attempt) {
var depMap = {};
var block = attempt.block;
var queue = new Queue(cmpPriority);
@ -456,11 +464,13 @@ Miner.prototype.fill = function fill(attempt) {
sigops += tx.getSigopsWeight(attempt.flags);
if (sigops > constants.block.MAX_SIGOPS_WEIGHT)
if (sigops > this.maxSigops)
continue;
if (priority) {
if (weight > this.priorityWeight || item.priority < this.minPriority) {
// Todo: Compare descendant rate with
// cumulative fees and cumulative vsize.
queue.cmp = cmpRate;
priority = false;
queue.push(item);