From 6959f9f19b888ccfc3acdcc6f4fe6320723a007a Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Mon, 4 Dec 2017 17:50:56 +0100 Subject: [PATCH] [enh] Put constants in a ProverConstants --- app/modules/prover/lib/blockProver.ts | 4 ++-- app/modules/prover/lib/constants.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/modules/prover/lib/blockProver.ts b/app/modules/prover/lib/blockProver.ts index 03676a8f4..f3e036770 100644 --- a/app/modules/prover/lib/blockProver.ts +++ b/app/modules/prover/lib/blockProver.ts @@ -201,12 +201,12 @@ export class BlockProver { this.logger.info('Done: #%s, %s in %ss instead of %ss (%s tests, ~%s tests/s)', block.number, proof.hash, (duration / 1000).toFixed(2), this.conf.avgGenTime, testsCount, testsPerSecond.toFixed(2)); this.logger.info('FOUND proof-of-work with %s leading zeros followed by [0-' + highMark + ']!', nbZeros); - if(this.conf.ecoMode === true && this.conf.nbCores*testsPerSecond > 300) { + if(this.conf.ecoMode === true && this.conf.nbCores*testsPerSecond > ProverConstants.ECO_MODE_MINIMAL_TESTS_PER_SECONDS) { if(this.conf.nbCores > 1) { this.logger.info("Reducing number of CPU cores "+this.conf.nbCores) this.conf.nbCores = this.conf.nbCores -1 } - else if(this.conf.cpu > 0.19){ + else if(this.conf.cpu > ProverConstants.ECO_MODE_MINIMAL_CPU){ let cpu:number = this.conf.cpu - 0.1 this.logger.info("Slowing down the CPU to "+cpu) this.changeCPU(cpu) diff --git a/app/modules/prover/lib/constants.ts b/app/modules/prover/lib/constants.ts index 2b8299c33..3a8d77c70 100644 --- a/app/modules/prover/lib/constants.ts +++ b/app/modules/prover/lib/constants.ts @@ -11,6 +11,9 @@ export const ProverConstants = { MIN_PEER_ID: 1, MAX_PEER_ID: 899, // Due to MAX_SAFE_INTEGER = 9007199254740991 (16 digits, and we use 11 digits for the nonce + 2 digits for core number => 3 digits for the peer, must be below 900) + ECO_MODE_MINIMAL_TESTS_PER_SECONDS: 300, + ECO_MODE_MINIMAL_CPU: 0.19, + NONCE_RANGE: 1000 * 1000 * 1000 * 100, POW_MAXIMUM_ACCEPTABLE_HANDICAP: 64, -- GitLab