Skip to content
Snippets Groups Projects
Commit 45601098 authored by Éloïs's avatar Éloïs
Browse files

[fix] #1126 add config prefix nodeId

parent 5009e4e2
No related branches found
No related tags found
No related merge requests found
......@@ -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.')
......
......@@ -21,6 +21,9 @@ export const ProverDependency = {
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;
},
......
......@@ -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,
......
......@@ -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
}
}
......
......@@ -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);
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment