Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Beddows committed Nov 30, 2016
2 parents ea2a601 + 6a839dd commit 6012c0b
Show file tree
Hide file tree
Showing 76 changed files with 5,543 additions and 2,961 deletions.
3 changes: 1 addition & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"quotmark": "single",
"strict" : true,
"globals": {
"gc": true,
"RequestSanitizer": true
"gc": true
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ Install PostgreSQL (version 9.5.2):

```
curl -sL "https://downloads.lisk.io/scripts/setup_postgresql.Linux" | bash -
sudo -u postgres createuser --createdb --password $USER
sudo -u postgres createuser --createdb $USER
createdb lisk_test
sudo -u postgres psql -d lisk_test -c "alter user "$USER" with password 'password';"
```

Install Node.js (version 0.12.x) + npm:
Expand Down
11 changes: 5 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var appConfig = require('./config.json');
var async = require('async');
var checkIpInList = require('./helpers/checkIpInList.js');
var extend = require('extend');
Expand Down Expand Up @@ -35,9 +34,7 @@ program
.option('-s, --snapshot <round>', 'verify snapshot')
.parse(process.argv);

if (program.config) {
appConfig = require(path.resolve(process.cwd(), program.config));
}
var appConfig = require('./helpers/config.js')(program.config);

if (program.port) {
appConfig.port = program.port;
Expand Down Expand Up @@ -71,6 +68,9 @@ if (program.snapshot) {
);
}

// Define top endpoint availability
process.env.TOP = appConfig.topAccounts;

var config = {
db: appConfig.db,
modules: {
Expand Down Expand Up @@ -163,7 +163,7 @@ d.run(function () {

require('./helpers/request-limiter')(app, appConfig);

app.use(compression({ level: 6 }));
app.use(compression({ level: 9 }));
app.use(cors());
app.options('*', cors());

Expand Down Expand Up @@ -226,7 +226,6 @@ d.run(function () {
var path = require('path');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var requestSanitizer = require('./helpers/request-sanitizer');
var queryParser = require('express-query-int');

scope.network.app.engine('html', require('ejs').renderFile);
Expand Down
14 changes: 11 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
"port": 8000,
"address": "0.0.0.0",
"version": "0.4.1",
"minVersion": "~0.4.0",
"fileLogLevel": "info",
"logFileName": "logs/lisk.log",
"consoleLogLevel": "info",
"trustProxy": false,
"topAccounts": false,
"db": {
"host": "localhost",
"port": 5432,
"database": "lisk_main",
"user": null,
"user": "",
"password": "password",
"poolSize": 20,
"poolSize": 95,
"poolIdleTimeout": 30000,
"reapIntervalMillis": 1000,
"logEvents": [
Expand Down Expand Up @@ -63,10 +65,16 @@
"delayAfter": 0,
"windowMs": 60000
},
"maxUpdatePeers": 20,
"timeout": 5000
}
},
"broadcasts": {
"broadcastInterval": 5000,
"broadcastLimit": 20,
"parallelLimit": 20,
"releaseLimit": 25,
"relayLimit": 2
},
"forging": {
"force": false,
"secret": [],
Expand Down
43 changes: 43 additions & 0 deletions helpers/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

var fs = require('fs');
var path = require('path');
var z_schema = require('./z_schema.js');
var configSchema = require('../schema/config.js');
var constants = require('../helpers/constants.js');

function Config (configPath) {
var configData = fs.readFileSync(path.resolve(process.cwd(), (configPath || 'config.json')), 'utf8');

if (!configData.length) {
console.log('Failed to read config file');
process.exit(1);
} else {
configData = JSON.parse(configData);
}

var validator = new z_schema();
var valid = validator.validate(configData, configSchema.config);

if (!valid) {
console.log('Failed to validate config data', validator.getLastErrors());
process.exit(1);
} else {
validateForce(configData);
return configData;
}
}

function validateForce (configData) {
if (configData.forging.force) {
var index = constants.nethashes.indexOf(configData.nethash);

if (index !== -1) {
console.log('Forced forging disabled for nethash', configData.nethash);
configData.forging.force = false;
}
}
}

// Exports
module.exports = Config;
19 changes: 14 additions & 5 deletions helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ module.exports = {
activeDelegates: 101,
addressLength: 208,
blockHeaderLength: 248,
blockReceiptTimeOut: 120, // 12 blocks
confirmationLength: 77,
epochTime: new Date(Date.UTC(2016, 4, 24, 17, 0, 0, 0)),
fees:{
fees: {
send: 10000000,
vote: 100000000,
secondsignature: 500000000,
Expand All @@ -16,16 +17,24 @@ module.exports = {
},
feeStart: 1,
feeStartVolume: 10000 * 100000000,
fixedPoint : Math.pow(10, 8),
forgingTimeOut: 500, // 50 blocks
fixedPoint: Math.pow(10, 8),
maxAddressesLength: 208 * 128,
maxAmount: 100000000,
maxClientConnections: 100,
maxConfirmations : 77 * 100,
maxConfirmations: 77 * 100,
maxPayloadLength: 1024 * 1024,
maxPeers: 100,
maxRequests: 10000 * 12,
maxSharedTxs: 100,
maxSignaturesLength: 196 * 256,
maxTxsPerBlock: 25,
maxTxsPerQueue: 5000,
minBroadhashConsensus: 51,
nethashes: [
// Mainnet
'ed14889723f24ecc54871d058d98ce91ff2f973192075c0155ba2b7b70ad2511',
// Testnet
'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba'
],
numberLength: 100000000,
requestLength: 104,
rewards: {
Expand Down
1 change: 1 addition & 0 deletions helpers/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
'5384302058030309746', // 869890
'9352922026980330230', // 925165
],
multisignatures: [],
votes: [
'5524930565698900323', // 20407
'11613486949732674475', // 123300
Expand Down
Loading

0 comments on commit 6012c0b

Please sign in to comment.