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
Olivier Beddows committed Apr 29, 2016
2 parents 9f7be64 + 0d6c947 commit 6d76f37
Show file tree
Hide file tree
Showing 49 changed files with 4,529 additions and 6,855 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blockchain.*
blockchain.db
dapps/
.DS_Store
.ed25519-node
Expand Down
22 changes: 12 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ module.exports = function (grunt) {
+ 'npm install && bower install && grunt release && cd ../ && '
+ util.format('cp %s/public/wallet.html %s/public/ && ', __dirname, version_dir)
+ util.format('cp %s/public/loading.html %s/public/ && ', __dirname, version_dir)
+ util.format('cp -rf %s/public/images %s/public/ && ', __dirname, version_dir)
+ util.format('cp -rf %s/public/partials %s/public/ && ', __dirname, version_dir)
+ util.format('cp -rf %s/public/static %s/public/ && ', __dirname, version_dir)
+ util.format('cp -Rf %s/public/images %s/public/ && ', __dirname, version_dir)
+ util.format('cp -Rf %s/public/partials %s/public/ && ', __dirname, version_dir)
+ util.format('cp -RfL %s/public/static %s/public/ && ', __dirname, version_dir)
+ util.format('mkdir -p %s/public/node_modules && ', version_dir)
+ util.format('cp -rf %s/public/node_modules/chart.js %s/public/node_modules && ', __dirname, version_dir)
+ util.format('cp -rf %s/public/node_modules/zeroclipboard %s/public/node_modules && ', __dirname, version_dir)
+ util.format('cp -Rf %s/public/node_modules/chart.js %s/public/node_modules && ', __dirname, version_dir)
+ util.format('cp -Rf %s/public/node_modules/zeroclipboard %s/public/node_modules && ', __dirname, version_dir)
+ util.format('mkdir -p %s/public/bower_components && ', version_dir)
+ util.format('mkdir -p %s/public/socket.io && ', version_dir)
+ util.format('cp -rf %s/public/bower_components/jquery %s/public/bower_components && ', __dirname, version_dir)
+ util.format('cp -rf %s/public/bower_components/materialize %s/public/bower_components && ', __dirname, version_dir)
+ util.format('cp -rf %s/public/bower_components/blob %s/public/bower_components && ', __dirname, version_dir)
+ util.format('cp -rf %s/public/bower_components/file-saver %s/public/bower_components', __dirname, version_dir);
+ util.format('cp -Rf %s/public/bower_components/jquery %s/public/bower_components && ', __dirname, version_dir)
+ util.format('cp -Rf %s/public/bower_components/materialize %s/public/bower_components && ', __dirname, version_dir)
+ util.format('cp -Rf %s/public/bower_components/blob %s/public/bower_components && ', __dirname, version_dir)
+ util.format('cp -Rf %s/public/bower_components/file-saver %s/public/bower_components', __dirname, version_dir);
}
},
folder: {
Expand All @@ -71,7 +71,9 @@ module.exports = function (grunt) {
compress: {
main: {
options: {
archive: version_dir + '.zip'
archive: version_dir + '.tar.gz',
mode: 'tgz',
level: 6
},
files: [
{ expand: true, cwd: release_dir, src: [config.version + '/**'], dest: './' }
Expand Down
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ sudo apt-get update
sudo apt-get install curl build-essential python
```

Install SQLite3 (version 3.8.2):
Install PostgreSQL (version 9.5.2):

```
curl -sL http://downloads.lisk.io/scripts/setup_sqlite3 | sudo -E bash -
sudo apt-get install -y sqlite3
curl -sL "https://downloads.lisk.io/scripts/setup_postgres.Linux" | bash -
sudo -u postgres createuser --createdb --password $USER
createdb lisk_test
```

Install Node.js (version 0.12.x) + npm:
Expand Down Expand Up @@ -45,6 +46,15 @@ Install node modules:
npm install
```

Install Lisk Node, a specialized version of Node.js used to execute dapps within a virtual machine:

```
wget https://downloads.lisk.io/lisk-node/lisk-node-Linux-x86_64.tar.gz
tar -zxvf lisk-node-Linux-x86_64.tar.gz
```

Lisk Node has to be in `[LISK_DIR]/nodejs/node`.

Load git submodules ([lisk-ui](https://github.com/LiskHQ/lisk-ui) and [lisk-js](https://github.com/LiskHQ/lisk-js)):

```
Expand Down Expand Up @@ -77,7 +87,7 @@ node app.js -p [port] -a [address] -c [config-path]

## Tests

Before running any tests, please ensure Lisk is configured to run on a local testnet (this is the default), and not the mainnet.
Before running any tests, please ensure Lisk is configured to run on the testnet (this is the default), and not the mainnet.

Install mocha (globally):

Expand All @@ -103,17 +113,17 @@ mocha test/lib/transactions.js
- Boris Povod <boris@crypti.me>
- Pavel Nekrasov <landgraf.paul@gmail.com>
- Sebastian Stupurac <stupurac.sebastian@gmail.com>
- Olivier Beddows <olivier@lisk.io>
- Oliver Beddows <oliver@lisk.io>

## License
The MIT License (MIT)

The MIT License (MIT)

Copyright (c) 2016 Lisk
Copyright (c) 2014-2015 Crypti
Copyright (c) 2014-2015 Crypti

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55 changes: 30 additions & 25 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ process.stdin.resume();

var versionBuild = fs.readFileSync(path.join(__dirname, 'build'), 'utf8');

if (typeof gc !== 'undefined') {
setInterval(function () {
gc();
}, 60000);
}

program
.version(packageJson.version)
.option('-c, --config <path>', 'Config file path')
Expand All @@ -26,12 +32,6 @@ program
.option('-l, --log <level>', 'Log level')
.parse(process.argv);

if (typeof gc !== 'undefined') {
setInterval(function () {
gc();
}, 60000);
}

if (program.config) {
appConfig = require(path.resolve(process.cwd(), program.config));
}
Expand Down Expand Up @@ -63,13 +63,13 @@ if (program.log) {
}

process.on('uncaughtException', function (err) {
// handle the error safely
// Handle error safely
logger.fatal('System error', { message: err.message, stack: err.stack });
process.emit('cleanup');
});

var config = {
"db": program.blockchain || "./blockchain.db",
"db": appConfig.db,
"modules": {
"server": "./modules/server.js",
"accounts": "./modules/accounts.js",
Expand All @@ -82,10 +82,8 @@ var config = {
"peer": "./modules/peer.js",
"delegates": "./modules/delegates.js",
"round": "./modules/round.js",
"contacts": "./modules/contacts.js",
"multisignatures": "./modules/multisignatures.js",
"dapps": "./modules/dapps.js",
"sia": "./modules/sia.js",
"crypto": "./modules/crypto.js",
"sql": "./modules/sql.js"
}
Expand All @@ -94,10 +92,12 @@ var config = {
var logger = new Logger({echo: appConfig.consoleLogLevel, errorLevel: appConfig.fileLogLevel});

var d = require('domain').create();

d.on('error', function (err) {
logger.fatal('Domain master', { message: err.message, stack: err.stack });
process.exit(0);
});

d.run(function () {
var modules = [];
async.auto({
Expand Down Expand Up @@ -214,7 +214,9 @@ d.run(function () {

network: ['config', function (cb, scope) {
var express = require('express');
var compression = require('compression');
var app = express();
app.use(compression({ level: 6 }))
var server = require('http').createServer(app);
var io = require('socket.io')(server);

Expand Down Expand Up @@ -282,11 +284,11 @@ d.run(function () {
scope.network.app.set('view engine', 'ejs');
scope.network.app.set('views', path.join(__dirname, 'public'));
scope.network.app.use(scope.network.express.static(path.join(__dirname, 'public')));
scope.network.app.use(bodyParser.urlencoded({extended: true, parameterLimit: 5000}));
scope.network.app.use(bodyParser.json());
scope.network.app.use(bodyParser.urlencoded({extended: true, limit: '2mb', parameterLimit: 5000}));
scope.network.app.use(bodyParser.json({limit: '2mb'}));
scope.network.app.use(methodOverride());

var ignore = ['id', 'name', 'lastBlockId', 'blockId', 'username', 'transactionId', 'address', 'recipientId', 'senderId', 'senderUsername', 'recipientUsername', 'previousBlock'];
var ignore = ['id', 'name', 'lastBlockId', 'blockId', 'transactionId', 'address', 'recipientId', 'senderId', 'previousBlock'];
scope.network.app.use(queryParser({
parser: function (value, radix, name) {
if (ignore.indexOf(name) >= 0) {
Expand All @@ -307,6 +309,9 @@ d.run(function () {
var parts = req.url.split('/');
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;

// Log client connections
logger.log(req.method + " " + req.url + " from " + ip);

/* Instruct browser to deny display of <frame>, <iframe> regardless of origin.
*
* RFC -> https://tools.ietf.org/html/rfc7034
Expand Down Expand Up @@ -351,12 +356,12 @@ d.run(function () {
});

scope.network.server.listen(scope.config.port, scope.config.address, function (err) {
scope.logger.log("Lisk started: " + scope.config.address + ":" + scope.config.port);
scope.logger.info("Lisk started: " + scope.config.address + ":" + scope.config.port);

if (!err) {
if (scope.config.ssl.enabled) {
scope.network.https.listen(scope.config.ssl.options.port, scope.config.ssl.options.address, function (err) {
scope.logger.log("Lisk https started: " + scope.config.ssl.options.address + ":" + scope.config.ssl.options.port);
scope.logger.info("Lisk https started: " + scope.config.ssl.options.address + ":" + scope.config.ssl.options.port);

cb(err, scope.network);
});
Expand Down Expand Up @@ -388,12 +393,12 @@ d.run(function () {
cb(null, new bus)
},

dbLite: function (cb) {
var dbLite = require('./helpers/dbLite.js');
dbLite.connect(config.db, cb);
db: function (cb) {
var db = require('./helpers/database.js');
db.connect(config.db, logger, cb);
},

logic: ['dbLite', 'bus', 'scheme', 'genesisblock', function (cb, scope) {
logic: ['db', 'bus', 'scheme', 'genesisblock', function (cb, scope) {
var Transaction = require('./logic/transaction.js');
var Block = require('./logic/block.js');
var Account = require('./logic/account.js');
Expand All @@ -402,8 +407,8 @@ d.run(function () {
bus: function (cb) {
cb(null, scope.bus);
},
dbLite: function (cb) {
cb(null, scope.dbLite);
db: function (cb) {
cb(null, scope.db);
},
scheme: function (cb) {
cb(null, scope.scheme);
Expand All @@ -413,19 +418,19 @@ d.run(function () {
block: genesisblock
});
},
account: ["dbLite", "bus", "scheme", 'genesisblock', function (cb, scope) {
account: ["db", "bus", "scheme", 'genesisblock', function (cb, scope) {
new Account(scope, cb);
}],
transaction: ["dbLite", "bus", "scheme", 'genesisblock', "account", function (cb, scope) {
transaction: ["db", "bus", "scheme", 'genesisblock', "account", function (cb, scope) {
new Transaction(scope, cb);
}],
block: ["dbLite", "bus", "scheme", 'genesisblock', "account", "transaction", function (cb, scope) {
block: ["db", "bus", "scheme", 'genesisblock', "account", "transaction", function (cb, scope) {
new Block(scope, cb);
}]
}, cb);
}],

modules: ['network', 'connect', 'config', 'logger', 'bus', 'sequence', 'dbSequence', 'balancesSequence', 'dbLite', 'logic', function (cb, scope) {
modules: ['network', 'connect', 'config', 'logger', 'bus', 'sequence', 'dbSequence', 'balancesSequence', 'db', 'logic', function (cb, scope) {
var tasks = {};
Object.keys(config.modules).forEach(function (name) {
tasks[name] = function (cb) {
Expand Down
Loading

0 comments on commit 6d76f37

Please sign in to comment.