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