protocol: constants changes.
This commit is contained in:
parent
e718caa1ff
commit
d338f62078
@ -297,7 +297,7 @@ Chain.prototype.verify = co(function* verify(block, prev) {
|
||||
|
||||
// Skip any blocks below the
|
||||
// last checkpoint.
|
||||
if (!this.options.segwit) {
|
||||
if (!this.options.witness) {
|
||||
// We can't skip this with segwit
|
||||
// enabled since the block may have
|
||||
// been malleated: we don't know
|
||||
|
||||
@ -97,26 +97,99 @@ function Mempool(options) {
|
||||
this.freeCount = 0;
|
||||
this.lastTime = 0;
|
||||
|
||||
this.limitFree = this.options.limitFree !== false;
|
||||
this.limitFreeRelay = this.options.limitFreeRelay || 15;
|
||||
this.relayPriority = this.options.relayPriority !== false;
|
||||
this.requireStandard = this.options.requireStandard != null
|
||||
? this.options.requireStandard
|
||||
: this.network.requireStandard;
|
||||
this.rejectAbsurdFees = this.options.rejectAbsurdFees !== false;
|
||||
this.prematureWitness = !!this.options.prematureWitness;
|
||||
this.paranoid = !!this.options.paranoid;
|
||||
this.replaceByFee = !!this.options.replaceByFee;
|
||||
this.limitFree = true;
|
||||
this.limitFreeRelay = 15;
|
||||
this.relayPriority = true;
|
||||
this.requireStandard = this.network.requireStandard;
|
||||
this.rejectAbsurdFees = true;
|
||||
this.prematureWitness = false;
|
||||
this.paranoidChecks = false;
|
||||
this.replaceByFee = false;
|
||||
|
||||
this.maxSize = options.maxSize || policy.MEMPOOL_MAX_SIZE;
|
||||
this.maxOrphans = options.maxOrphans || policy.MEMPOOL_MAX_ORPHANS;
|
||||
this.maxAncestors = options.maxAncestors || policy.MEMPOOL_MAX_ANCESTORS;
|
||||
this.expiryTime = options.expiryTime || policy.MEMPOOL_EXPIRY_TIME;
|
||||
this.maxSize = policy.MEMPOOL_MAX_SIZE;
|
||||
this.maxOrphans = policy.MEMPOOL_MAX_ORPHANS;
|
||||
this.maxAncestors = policy.MEMPOOL_MAX_ANCESTORS;
|
||||
this.expiryTime = policy.MEMPOOL_EXPIRY_TIME;
|
||||
this.minRelay = this.network.minRelay;
|
||||
|
||||
this._initOptions(options);
|
||||
}
|
||||
|
||||
util.inherits(Mempool, AsyncObject);
|
||||
|
||||
/**
|
||||
* Initialize options.
|
||||
* @param {Object} options
|
||||
* @private
|
||||
*/
|
||||
|
||||
Mempool.prototype._initOptions = function _initOptions(options) {
|
||||
if (options.limitFree != null) {
|
||||
assert(typeof options.limitFree === 'boolean');
|
||||
this.limitFree = options.limitFree;
|
||||
}
|
||||
|
||||
if (options.limitFreeRelay != null) {
|
||||
assert(util.isNumber(options.limitFreeRelay));
|
||||
this.limitFreeRelay = options.limitFreeRelay;
|
||||
}
|
||||
|
||||
if (options.relayPriority != null) {
|
||||
assert(typeof options.relayPriority === 'boolean');
|
||||
this.relayPriority = options.relayPriority;
|
||||
}
|
||||
|
||||
if (options.requireStandard != null) {
|
||||
assert(typeof options.requireStandard === 'boolean');
|
||||
this.requireStandard = options.requireStandard;
|
||||
}
|
||||
|
||||
if (options.rejectAbsurdFees != null) {
|
||||
assert(typeof options.rejectAbsurdFees === 'boolean');
|
||||
this.rejectAbsurdFees = options.rejectAbsurdFees;
|
||||
}
|
||||
|
||||
if (options.prematureWitness != null) {
|
||||
assert(typeof options.prematureWitness === 'boolean');
|
||||
this.prematureWitness = options.prematureWitness;
|
||||
}
|
||||
|
||||
if (options.paranoidChecks != null) {
|
||||
assert(typeof options.paranoidChecks === 'boolean');
|
||||
this.paranoidChecks = options.paranoidChecks;
|
||||
}
|
||||
|
||||
if (options.replaceByFee != null) {
|
||||
assert(typeof options.replaceByFee === 'boolean');
|
||||
this.replaceByFee = options.replaceByFee;
|
||||
}
|
||||
|
||||
if (options.maxSize != null) {
|
||||
assert(util.isNumber(options.maxSize));
|
||||
this.maxSize = options.maxSize;
|
||||
}
|
||||
|
||||
if (options.maxOrphans != null) {
|
||||
assert(util.isNumber(options.maxOrphans));
|
||||
this.maxOrphans = options.maxOrphans;
|
||||
}
|
||||
|
||||
if (options.maxAncestors != null) {
|
||||
assert(util.isNumber(options.maxAncestors));
|
||||
this.maxAncestors = options.maxAncestors;
|
||||
}
|
||||
|
||||
if (options.expiryTime != null) {
|
||||
assert(util.isNumber(options.expiryTime));
|
||||
this.expiryTime = options.expiryTime;
|
||||
}
|
||||
|
||||
if (options.minRelay != null) {
|
||||
assert(util.isNumber(options.minRelay));
|
||||
this.minRelay = options.minRelay;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the chain, wait for the database to load.
|
||||
* @alias Mempool#open
|
||||
@ -921,7 +994,7 @@ Mempool.prototype.verify = co(function* verify(entry, view) {
|
||||
}
|
||||
|
||||
// Paranoid checks.
|
||||
if (this.paranoid) {
|
||||
if (this.paranoidChecks) {
|
||||
flags = Script.flags.MANDATORY_VERIFY_FLAGS;
|
||||
result = yield this.verifyResult(tx, view, flags);
|
||||
assert(result, 'BUG: Verify failed for mandatory but not standard.');
|
||||
@ -961,20 +1034,15 @@ Mempool.prototype.verifyInputs = co(function* verifyInputs(tx, view, flags) {
|
||||
if (yield tx.verifyAsync(view, flags))
|
||||
return;
|
||||
|
||||
if (!(flags & Script.flags.UNSTANDARD_VERIFY_FLAGS)) {
|
||||
throw new VerifyError(tx,
|
||||
'nonstandard',
|
||||
'non-mandatory-script-verify-flag',
|
||||
0);
|
||||
}
|
||||
if (flags & Script.flags.ONLY_STANDARD_VERIFY_FLAGS) {
|
||||
flags &= ~Script.flags.ONLY_STANDARD_VERIFY_FLAGS;
|
||||
|
||||
flags &= ~Script.flags.UNSTANDARD_VERIFY_FLAGS;
|
||||
|
||||
if (yield tx.verifyAsync(view, flags)) {
|
||||
throw new VerifyError(tx,
|
||||
'nonstandard',
|
||||
'non-mandatory-script-verify-flag',
|
||||
0);
|
||||
if (yield tx.verifyAsync(view, flags)) {
|
||||
throw new VerifyError(tx,
|
||||
'nonstandard',
|
||||
'non-mandatory-script-verify-flag',
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
throw new VerifyError(tx,
|
||||
|
||||
@ -15,7 +15,7 @@ var pkg = require('../../package.json');
|
||||
* @default
|
||||
*/
|
||||
|
||||
exports.PROTOCOL_VERSION = 70014;
|
||||
exports.PROTOCOL_VERSION = 70015;
|
||||
|
||||
/**
|
||||
* Minimum protocol version we're willing to talk to.
|
||||
|
||||
@ -222,7 +222,7 @@ exports.flags.STANDARD_VERIFY_FLAGS = 0
|
||||
* @default
|
||||
*/
|
||||
|
||||
exports.flags.UNSTANDARD_VERIFY_FLAGS =
|
||||
exports.flags.ONLY_STANDARD_VERIFY_FLAGS =
|
||||
exports.flags.STANDARD_VERIFY_FLAGS & ~exports.flags.MANDATORY_VERIFY_FLAGS;
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user