minor.
This commit is contained in:
parent
75aad4e771
commit
821f1175cc
@ -755,8 +755,10 @@ Chain.prototype._checkDuplicates = function _checkDuplicates(block, prev, callba
|
||||
if (this.isGenesis(block))
|
||||
return callback();
|
||||
|
||||
if (this.network.block.bip34height === -1 || height <= this.network.block.bip34height)
|
||||
if (this.network.block.bip34height === -1
|
||||
|| height <= this.network.block.bip34height) {
|
||||
return this._findDuplicates(block, prev, callback);
|
||||
}
|
||||
|
||||
this.db.get(this.network.block.bip34height, function(err, entry) {
|
||||
if (err)
|
||||
|
||||
@ -59,7 +59,7 @@ Coin.prototype.fromOptions = function fromOptions(options) {
|
||||
this.hash = options.hash;
|
||||
this.index = options.index;
|
||||
|
||||
assert(typeof this.version === 'number');
|
||||
assert(utils.isNumber(this.version));
|
||||
assert(utils.isNumber(this.height));
|
||||
assert(typeof this.value === 'number');
|
||||
assert(this.script instanceof bcoin.script);
|
||||
|
||||
@ -24,37 +24,31 @@ var ScriptError = bcoin.errors.ScriptError;
|
||||
* Refers to the witness field of segregated witness transactions.
|
||||
* @exports Witness
|
||||
* @constructor
|
||||
* @param {Buffer[]|Buffer|NakedWitness} items - Array of
|
||||
* stack items or raw witness buffer.
|
||||
* @param {Buffer[]|NakedWitness} items - Array of
|
||||
* stack items.
|
||||
* @property {Buffer[]} items
|
||||
* @property {Script?} redeem
|
||||
* @property {Number} length
|
||||
*/
|
||||
|
||||
function Witness(items) {
|
||||
if (items instanceof Witness)
|
||||
return items;
|
||||
function Witness(options) {
|
||||
if (options instanceof Witness)
|
||||
return options;
|
||||
|
||||
if (!(this instanceof Witness))
|
||||
return new Witness(items);
|
||||
return new Witness(options);
|
||||
|
||||
this.items = [];
|
||||
this.redeem = null;
|
||||
|
||||
if (items)
|
||||
this.fromOptions(items);
|
||||
if (options)
|
||||
this.fromOptions(options);
|
||||
}
|
||||
|
||||
Witness.prototype.fromOptions = function fromOptions(items) {
|
||||
if (items.items)
|
||||
items = items.items;
|
||||
|
||||
this.items = items;
|
||||
|
||||
Witness.prototype.fromOptions = function fromOptions(options) {
|
||||
this.items = options.items || options;
|
||||
this.redeem = null;
|
||||
|
||||
assert(Array.isArray(this.items));
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
@ -1034,19 +1028,19 @@ Stack.isStack = function isStack(obj) {
|
||||
* @property {Number} length
|
||||
*/
|
||||
|
||||
function Script(raw) {
|
||||
if (raw instanceof Script)
|
||||
return raw;
|
||||
function Script(options) {
|
||||
if (options instanceof Script)
|
||||
return options;
|
||||
|
||||
if (!(this instanceof Script))
|
||||
return new Script(raw);
|
||||
return new Script(options);
|
||||
|
||||
this.raw = STACK_FALSE;
|
||||
this.code = [];
|
||||
this.redeem = null;
|
||||
|
||||
if (raw)
|
||||
this.fromOptions(raw);
|
||||
if (options)
|
||||
this.fromOptions(options);
|
||||
}
|
||||
|
||||
Script.prototype.fromOptions = function fromOptions(options) {
|
||||
@ -1066,7 +1060,6 @@ Script.prototype.fromOptions = function fromOptions(options) {
|
||||
|
||||
this.raw = raw;
|
||||
this.code = code;
|
||||
this.redeem = null;
|
||||
|
||||
if (!this.raw) {
|
||||
assert(this.code);
|
||||
@ -1082,10 +1075,10 @@ Script.prototype.fromOptions = function fromOptions(options) {
|
||||
return this;
|
||||
};
|
||||
|
||||
Script.fromOptions = function fromOptions(raw) {
|
||||
if (raw instanceof Script)
|
||||
return raw;
|
||||
return new Script().fromOptions(raw);
|
||||
Script.fromOptions = function fromOptions(options) {
|
||||
if (options instanceof Script)
|
||||
return options;
|
||||
return new Script().fromOptions(options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -644,47 +644,12 @@ utils.merge = function merge(target) {
|
||||
|
||||
/**
|
||||
* Assertion.
|
||||
* @function
|
||||
* @param {Boolean} value - Expression.
|
||||
* @param {String?} message - Optional error message.
|
||||
*/
|
||||
|
||||
utils.assert = function _assert(value, message) {
|
||||
if (!value) {
|
||||
throw new assert.AssertionError({
|
||||
message: message,
|
||||
actual: value,
|
||||
expected: true,
|
||||
operator: '==',
|
||||
stackStartFunction: _assert
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
utils.merge(utils.assert, assert);
|
||||
|
||||
utils.assert.fatal = function fatal(value, message) {
|
||||
var err;
|
||||
|
||||
if (!value) {
|
||||
if (!message)
|
||||
message = 'Assertion failed (fatal exception)';
|
||||
|
||||
err = new assert.AssertionError({
|
||||
message: message,
|
||||
actual: value,
|
||||
expected: true,
|
||||
operator: '==',
|
||||
stackStartFunction: fatal
|
||||
});
|
||||
|
||||
if (process.exit) {
|
||||
console.error(err.stack + '');
|
||||
process.exit(1);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
utils.assert = assert;
|
||||
|
||||
/**
|
||||
* Safely convert satoshis to a BTC string.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user