Skip to content

Commit

Permalink
Reverted merge
Browse files Browse the repository at this point in the history
  • Loading branch information
djordjekovac committed Apr 1, 2022
1 parent cf79cbd commit bb351b2
Show file tree
Hide file tree
Showing 33 changed files with 11,764 additions and 2,954 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

37 changes: 0 additions & 37 deletions .github/ISSUE_TEMPLATE/bug_report_v6.md

This file was deleted.

21 changes: 0 additions & 21 deletions .github/release-drafter-template.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/TEST-release.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/TEST-unit.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/release-drafter-config.yml

This file was deleted.

73 changes: 6 additions & 67 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor": 5,
"replicationFactor" : 5,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand All @@ -36,59 +36,8 @@
],
"telemetryHub": {
"enabled": false,
"packages": [
"ot-telemetry-collector"
],
"packages": ["ot-telemetry-collector"],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
}
},
"test": {
"appDataPath": "data",
"autoUpdate": {
"enabled": false,
"branch": "v6/develop",
"backupDirectory": "../backup"
},
"blockchain": [
{
"blockchainTitle": "ganache",
"networkId": "ganache::testnet",
"hubContractAddress": "",
"rpcEndpoints": [
"http://localhost:7545"
]
}
],
"graphDatabase": {
"implementation": "GraphDB",
"url": "http://localhost:7200",
"name": "node0",
"username": "admin",
"password": ""
},
"logLevel": "trace",
"replicationFactor": 5,
"rpcPort": 8900,
"network": {
"port": 9000,
"bootstrap": []
},
"ipWhitelist": [
"::1",
"127.0.0.1"
],
"telemetryHub": {
"enabled": false,
"packages": [
"ot-telemetry-collector"
],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
}
},
"testnet": {
Expand Down Expand Up @@ -116,7 +65,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor": 5,
"replicationFactor" : 5,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand All @@ -132,13 +81,8 @@
],
"telemetryHub": {
"enabled": true,
"packages": [
"ot-telemetry-collector"
],
"packages": ["ot-telemetry-collector"],
"url": "https://polaris.delta.origin-trail.network/metrics/"
},
"operationalDatabase": {
"databaseName": "operationaldb"
}
},
"mainnet": {
Expand All @@ -157,7 +101,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor": 5,
"replicationFactor" : 5,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand All @@ -169,13 +113,8 @@
],
"telemetryHub": {
"enabled": false,
"packages": [
"ot-telemetry-collector"
],
"packages": ["ot-telemetry-collector"],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
}
}
}
1 change: 1 addition & 0 deletions config/sequelizeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require('dotenv').config();
module.exports = {
username: 'root',
password: '',
database: 'operationaldb',
dialect: 'mysql',
host: 'localhost',
port: 3306,
Expand Down
33 changes: 15 additions & 18 deletions external/libp2p-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ class Libp2pService {
listen: [`/ip4/0.0.0.0/tcp/${this.config.port}`] // for production
// announce: ['/dns4/auto-relay.libp2p.io/tcp/443/wss/p2p/QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3']
};
let id;
let privKey;

if (!this.config.peerId) {
if (!this.config.privateKey) {
id = await PeerId.create({bits: 1024, keyType: 'RSA'})
privKey = id.toJSON().privKey;
} else {
privKey = this.config.privateKey;
id = await PeerId.createFromPrivKey(this.config.privateKey);
const configFile = JSON.parse(fs.readFileSync(this.config.configFilename));
if (!configFile.network.privateKey) {
const id = await PeerId.create({bits: 1024, keyType: 'RSA'})
configFile.network.privateKey = id.toJSON().privKey;
if(process.env.NODE_ENV !== 'development') {
fs.writeFileSync(this.config.configFilename, JSON.stringify(configFile, null, 2));
}
}
this.config.privateKey = privKey;
this.config.peerId = id;
this.config.privateKey = configFile.network.privateKey;
this.config.peerId = await PeerId.createFromPrivKey(this.config.privateKey);
}

initializationObject.peerId = this.config.peerId;
Expand All @@ -83,10 +83,7 @@ class Libp2pService {
const peerId = this.node.peerId._idB58String;
this.config.id = peerId;
this.logger.info(`Network ID is ${peerId}, connection port is ${port}`);
resolve({
peerId: id,
privateKey: privKey,
});
resolve(result);
})
.catch((err) => {
reject(err);
Expand Down Expand Up @@ -291,7 +288,7 @@ class Libp2pService {
constants.NETWORK_API_BLACK_LIST_TIME_WINDOW_MINUTES -
(Date.now() - this.blackList[remotePeerId]) / (1000 * 60)
);

if(remainingMinutes > 0) {
this.logger.info(`Blocking request from ${remotePeerId}. Node is blacklisted for ${remainingMinutes} minutes.`);

Expand All @@ -300,7 +297,7 @@ class Libp2pService {
delete this.blackList[remotePeerId]
}
}

if(await this.rateLimiter.spamDetection.limit(remotePeerId)) {
this.blackList[remotePeerId] = Date.now();
this.logger.info(
Expand All @@ -312,8 +309,8 @@ class Libp2pService {
this.logger.info(`Blocking request from ${remotePeerId}. Max number of requests exceeded.`);

return true;
}

}
return false;
}

Expand Down
8 changes: 1 addition & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ config = rc(pjson.name, defaultConfig);

(async () => {
try {
let userConfig = null;
if (process.env.NODE_ENV === 'development' && process.argv.length === 3) {
const configurationFilename = process.argv[2];
userConfig = JSON.parse(fs.readFileSync(process.argv[2]));
userConfig.configFilename = configurationFilename;
}
const node = new OTNode(userConfig);
const node = new OTNode();
await node.start();
} catch (e) {
console.error(`Error occurred while starting new version, error message: ${e}. ${e.stack}`);
Expand Down
Loading

0 comments on commit bb351b2

Please sign in to comment.