mempool. constants.

This commit is contained in:
Christopher Jeffrey 2016-03-29 00:43:05 -07:00
parent ea4d0dee03
commit 3d6892cbe9
4 changed files with 26 additions and 13 deletions

View File

@ -629,7 +629,7 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, peer, c
else
sigops += tx.getSigops();
if (sigops > constants.script.maxBlockSigops) {
if (sigops > constants.block.maxSigops) {
utils.debug('Block has too many sigops: %s', block.rhash);
self.emit('verify-error',
block, 'invalid', 'bad-blk-sigops', 100, peer);

View File

@ -40,6 +40,7 @@ function Mempool(node, options) {
this.db = null;
this.tx = null;
this.size = 0;
this.orphans = 0;
this.freeCount = 0;
this.lastTime = 0;
@ -63,6 +64,7 @@ Mempool.mandatory = constants.flags.MANDATORY_VERIFY_FLAGS;
Mempool.ANCESTOR_LIMIT = 25;
Mempool.MAX_MEMPOOL_SIZE = 300 << 20;
Mempool.MEMPOOL_EXPIRY = 72 * 60 * 60;
Mempool.MAX_ORPHAN_TX = 100;
Mempool.prototype._lock = function _lock(func, args, force) {
return this.locker.lock(func, args, force);
@ -225,6 +227,7 @@ Mempool.prototype.purgeOrphans = function purgeOrphans(callback) {
return callback(err);
self.size = size;
self.orphans = 0;
return callback();
});
@ -448,7 +451,7 @@ Mempool.prototype.verify = function verify(tx, callback) {
0));
}
if (tx.getSigops(true) > constants.script.maxSigops) {
if (tx.getSigops(true) > constants.tx.maxSigops) {
return callback(new VerifyError(
'nonstandard',
'bad-txns-too-many-sigops',
@ -670,7 +673,18 @@ Mempool.prototype.storeOrphan = function storeOrphan(tx, callback, force) {
if (err)
return callback(err);
self.orphans++;
batch.put('m/D/' + hash, tx.toExtended(true));
if (self.orphans > Mempool.MAX_ORPHAN_TX) {
return self.purgeOrphans(function(err) {
if (err)
return callback(err);
batch.write(callback);
});
}
batch.write(callback);
});
};
@ -731,6 +745,7 @@ Mempool.prototype.resolveOrphans = function resolveOrphans(tx, callback, force)
});
if (orphan.hasCoins()) {
self.orphans--;
batch.del('m/D/' + orphanHash);
return self.verify(orphan, function(err) {
if (err) {

View File

@ -206,30 +206,25 @@ exports.hashTypeByVal = Object.keys(exports.hashType).reduce(function(out, type)
exports.block = {
maxSize: 1000000,
maxCost: 4000000,
maxSigops: 1000000 / 50,
maxSigopsCost: 4000000 / 50,
maxOrphanTx: 1000000 / 100,
medianTimespan: 11,
bip16time: 1333238400
bip16time: 1333238400,
sighashLimit: 1300000000
};
exports.tx = {
version: 1,
maxSize: 100000,
maxCost: 400000,
minFee: 10000,
bareMultisig: true,
freeThreshold: exports.coin.muln(144).divn(250),
maxFreeSize: 1000,
maxSigops: exports.block.maxSigops / 5,
coinbaseMaturity: 100
};
exports.tx.dustThreshold = new bn(182)
.muln(exports.tx.minFee)
.divn(1000)
.muln(3)
.toNumber();
exports.tx.dustThreshold = 182 * exports.tx.minFee / 1000 * 3;
exports.script = {
maxSize: 10000,
@ -237,9 +232,7 @@ exports.script = {
maxPush: 520,
maxOps: 201,
maxPubkeysPerMultisig: 20,
maxBlockSigops: exports.block.maxSize / 50,
maxScripthashSigops: 15,
maxTxSigops: exports.block.maxSize / 50 / 5,
maxOpReturnBytes: 83,
maxOpReturn: 80
};

View File

@ -151,6 +151,11 @@ main.deployments = {
startTime: 1459468800, // April 1st, 2016
timeout: 1491004800 // April 1st, 2017
}
// bip109: {
// bit: 28,
// startTime: 1453939200, // Jan 28th, 2016
// timeout: 1514764800 // Jan 1st, 2018
// }
};
main.height = -1;