miner: options.
This commit is contained in:
parent
bc00697adb
commit
814c18437d
@ -50,34 +50,77 @@ function Miner(options) {
|
||||
|
||||
this.version = -1;
|
||||
this.addresses = [];
|
||||
this.coinbaseFlags = options.coinbaseFlags || 'mined by bcoin';
|
||||
this.coinbaseFlags = new Buffer('mined by bcoin', 'ascii');
|
||||
|
||||
this.minWeight = 0;
|
||||
this.maxWeight = 750000 * 4;
|
||||
this.priorityWeight = 50000 * 4;
|
||||
this.maxWeight = 750000 * constants.WITNESS_SCALE_FACTOR;
|
||||
this.priorityWeight = 50000 * constants.WITNESS_SCALE_FACTOR;
|
||||
this.minPriority = constants.tx.FREE_THRESHOLD;
|
||||
|
||||
this._init(options);
|
||||
this._initOptions(options);
|
||||
this._init();
|
||||
}
|
||||
|
||||
utils.inherits(Miner, AsyncObject);
|
||||
|
||||
/**
|
||||
* Initialize the miner options.
|
||||
* @private
|
||||
*/
|
||||
|
||||
Miner.prototype._initOptions = function _initOptions(options) {
|
||||
var i, flags;
|
||||
|
||||
if (options.version != null) {
|
||||
assert(utils.isNumber(options.version));
|
||||
this.version = options.version;
|
||||
}
|
||||
|
||||
if (options.address)
|
||||
this.addAddress(options.address);
|
||||
|
||||
if (options.addresses) {
|
||||
assert(Array.isArray(options.addresses));
|
||||
for (i = 0; i < options.addresses.length; i++)
|
||||
this.addAddress(options.addresses[i]);
|
||||
}
|
||||
|
||||
if (options.coinbaseFlags) {
|
||||
flags = options.coinbaseFlags;
|
||||
if (typeof flags === 'string')
|
||||
flags = new Buffer(flags, 'utf8');
|
||||
assert(Buffer.isBuffer(flags));
|
||||
this.coinbaseFlags = flags;
|
||||
}
|
||||
|
||||
if (options.minWeight != null) {
|
||||
assert(utils.isNumber(options.minWeight));
|
||||
this.minWeight = options.minWeight;
|
||||
}
|
||||
|
||||
if (options.maxWeight != null) {
|
||||
assert(utils.isNumber(options.maxWeight));
|
||||
this.maxWeight = options.maxWeight;
|
||||
}
|
||||
|
||||
if (options.priorityWeight != null) {
|
||||
assert(utils.isNumber(options.priorityWeight));
|
||||
this.priorityWeight = options.priorityWeight;
|
||||
}
|
||||
|
||||
if (options.minPriority != null) {
|
||||
assert(utils.isNumber(options.minPriority));
|
||||
this.minPriority = options.minPriority;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the miner.
|
||||
* @private
|
||||
*/
|
||||
|
||||
Miner.prototype._init = function _init(options) {
|
||||
Miner.prototype._init = function _init() {
|
||||
var self = this;
|
||||
var i;
|
||||
|
||||
if (options.address)
|
||||
this.addAddress(options.address);
|
||||
|
||||
if (options.addresses) {
|
||||
for (i = 0; i < options.addresses.length; i++)
|
||||
this.addAddress(options.addresses[i]);
|
||||
}
|
||||
|
||||
this.chain.on('tip', function(tip) {
|
||||
if (!self.attempt)
|
||||
|
||||
@ -113,7 +113,6 @@ function Peer(pool, addr, socket) {
|
||||
this.bip150 = null;
|
||||
this.lastSend = 0;
|
||||
this.lastRecv = 0;
|
||||
this.outgoing = 0;
|
||||
|
||||
this.challenge = null;
|
||||
this.lastPong = -1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user