diff --git a/app/cli.ts b/app/cli.ts index a59414cf7e7a48cd971df993a02f18924e1fac4d..cedf3a7fa3b2bf3705896010e990d2474b85cbe4 100644 --- a/app/cli.ts +++ b/app/cli.ts @@ -42,6 +42,7 @@ export const ExecuteCommand = () => { .option('--remep <endpoint>', 'With `config` command, remove given endpoint to the list of endpoints of this node') .option('--cpu <percent>', 'Percent of CPU usage for proof-of-work computation', parsePercent) + .option('--prefix <nodeId>', 'Prefix node id for the first character of nonce', parseInt) .option('-c, --currency <name>', 'Name of the currency managed by this node.') diff --git a/app/modules/prover/index.ts b/app/modules/prover/index.ts index 094888333fd0ad2f767be0bf9cbf2cadb261d540..b0b9cec8b6155b7e35fe2cf5c32f2c8c7177eac6 100644 --- a/app/modules/prover/index.ts +++ b/app/modules/prover/index.ts @@ -14,13 +14,16 @@ const async = require('async'); export const ProverDependency = { duniter: { - + /*********** Permanent prover **************/ config: { onLoading: async (conf:ConfDTO) => { if (conf.cpu === null || conf.cpu === undefined) { conf.cpu = Constants.DEFAULT_CPU; } + if (conf.prefix === null || conf.prefix === undefined) { + conf.prefix = Constants.DEFAULT_PEER_ID; + } conf.powSecurityRetryDelay = Constants.POW_SECURITY_RETRY_DELAY; conf.powMaxHandicap = Constants.POW_MAXIMUM_ACCEPTABLE_HANDICAP; }, diff --git a/app/modules/prover/lib/constants.ts b/app/modules/prover/lib/constants.ts index 9db6278dd4a05313c9ca5e9c9bd19ba2c795b6a8..0b10fbf483f47319caa3327aa9fe27c4402f2e3e 100644 --- a/app/modules/prover/lib/constants.ts +++ b/app/modules/prover/lib/constants.ts @@ -6,6 +6,7 @@ export const Constants = { POW_MINIMAL_TO_SHOW: 2, DEFAULT_CPU: 0.6, + DEFAULT_PEER_ID: 1, NONCE_RANGE: 1000 * 1000 * 1000 * 100, diff --git a/app/modules/prover/lib/prover.ts b/app/modules/prover/lib/prover.ts index d14b21c6871c1609eea71e745168459743b26357..182f5e3fec4ef7077efa1d13ace7c21c95ba7dbb 100644 --- a/app/modules/prover/lib/prover.ts +++ b/app/modules/prover/lib/prover.ts @@ -17,9 +17,9 @@ export class Prover extends stream.Transform { if (obj) { if (obj.bcEvent && obj.bcEvent === OtherConstants.BC_EVENT.HEAD_CHANGED || obj.bcEvent === OtherConstants.BC_EVENT.SWITCHED) { this.permaProver.blockchainChanged(obj.block); - } else if (obj.nodeIndexInPeers !== undefined) { + } /*else if (obj.nodeIndexInPeers !== undefined) { this.permaProver.prover.changePoWPrefix((obj.nodeIndexInPeers + 1) * 10); // We multiply by 10 to give room to computers with < 100 cores - } else if (obj.cpu !== undefined) { + }*/ else if (obj.cpu !== undefined) { this.permaProver.prover.changeCPU(obj.cpu); // We multiply by 10 to give room to computers with < 100 cores } } diff --git a/app/service/PeeringService.ts b/app/service/PeeringService.ts index a19181209a700f5e3eec2298bafa9031852b493c..c056fe89f45c3e4071b233c32edc794273315314 100644 --- a/app/service/PeeringService.ts +++ b/app/service/PeeringService.ts @@ -161,7 +161,7 @@ export class PeeringService { const localEndpoints = await this.server.getEndpoints() const localNodeNotListed = !peerEntityOld.containsAllEndpoints(localEndpoints) const current = localNodeNotListed && (await this.dal.getCurrentBlockOrNull()); - if (!localNodeNotListed) { + /*if (!localNodeNotListed) { const indexOfThisNode = PeerDTO.indexOfFirst(localEndpoints, peerEntity.endpoints) if (indexOfThisNode !== -1) { this.server.push({ @@ -170,7 +170,7 @@ export class PeeringService { } else { logger.warn('This node has his interface listed in the peer document, but its index cannot be found.'); } - } + }*/ if (localNodeNotListed && (!current || current.number > blockNumber)) { // Document with pubkey of local peer, but doesn't contain local interface: we must add it this.generateSelfPeer(this.conf); diff --git a/index.ts b/index.ts index ce96dcd7a489f79d0b6a3645de40bd2b473a1644..08eaccdc996ed0823622101a88969b4f4e59a373 100644 --- a/index.ts +++ b/index.ts @@ -443,6 +443,7 @@ function commandLineConf(program:any, conf:any = {}) { const cli = { currency: program.currency, cpu: program.cpu, + prefix: program.prefix, server: { port: program.port, }, @@ -467,6 +468,7 @@ function commandLineConf(program:any, conf:any = {}) { if (cli.currency) conf.currency = cli.currency; if (cli.server.port) conf.port = cli.server.port; if (cli.cpu) conf.cpu = Math.max(0.01, Math.min(1.0, cli.cpu)); + if (cli.prefix) conf.prefix = Math.max(1, Math.min(9, cli.prefix)); if (cli.logs.http) conf.httplogs = true; if (cli.logs.nohttp) conf.httplogs = false; if (cli.db.mport) conf.mport = cli.db.mport;