Skip to content

Commit

Permalink
Merge pull request #70 from Adamant-im/dev
Browse files Browse the repository at this point in the history
v0.8.1
  • Loading branch information
martiliones authored Apr 13, 2023
2 parents 5214996 + 12be019 commit 95df4fc
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 22 deletions.
35 changes: 24 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
dapps/
docs/jsdoc/
release
ssl/

# Config files
config.json
test/config.json
sftp-config.json

# Logs
logs/*.log
stacktrace*

# Code Editors
.DS_Store
.ed25519-node
.idea/
.project
.vscode/
__MACOSX/
dapps/
docs/jsdoc/
logs/*.log
node_modules
nodejs/
npm-debug.log
release
ssl/
stacktrace*

# Tests
test/.coverage-unit
test/.coverage
test/.nyc_output

# Temporary data
tmp
sftp-config.json
*.swp
*.swo
package-lock.json

# npm
node_modules
package-lock.json
npm-debug.log
nodejs
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ F. e.,
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib libpq-dev
# Create user if you are working from superuser
adduser adamant
sudo usermod -aG sudo adamant
su - adamant
# Create db
sudo -u postgres createuser --createdb $USER
createdb adamant_test
Expand All @@ -107,12 +107,26 @@ cd adamant
npm install
```

Then set db.password in config:
Copy the default config file by running the following command:

```
cp config.default.json config.json
```

Edit the "config.json" file using your preferred text editor, for example, Vim or Nano.

```
nano config.json
```

or

```
vim config.json
```

Make the necessary changes to the configuration values in the file. At minimum, you should change the value of the `db.password` property to your actual database password.

### Bootstrap with a blockchain image

Blockchain image saves time on node sync but you must completely trust the image. If you skip this step, your node will check every single transaction, which takes time (up for several days).
Expand Down Expand Up @@ -190,9 +204,9 @@ This program is free software: you can redistribute it and/or modify it under th

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the [GNU General Public License](https://github.com/LiskHQ/lisk/tree/master/LICENSE) along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the [GNU General Public License](https://github.com/LiskHQ/lisk/tree/master/LICENSE) along with this program. If not, see <http://www.gnu.org/licenses/>.

***
---

This program also incorporates work previously released with lisk `0.7.0` (and earlier) versions under the [MIT License](https://opensource.org/licenses/MIT). To comply with the requirements of that license, the following permission notice, applicable to those parts of the code only, is included below:

Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ d.run(function () {
}

if (!appConfig.cors) {
appConfig.cors = { origin: true };
appConfig.cors = { origin: '*' };
}

appConfig.cors.credentials = true;
Expand Down
127 changes: 127 additions & 0 deletions config.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"port": 36666,
"address": "0.0.0.0",
"fileLogLevel": "warn",
"logFileName": "logs/adamant.log",
"consoleLogLevel": "info",
"trustProxy": false,
"topAccounts": false,
"cacheEnabled": false,
"db": {
"host": "localhost",
"port": 5432,
"database": "adamant_main",
"user": "adamant",
"password": "password",
"poolSize": 95,
"poolIdleTimeout": 30000,
"reapIntervalMillis": 1000,
"logEvents": [
"error"
]
},
"redis": {
"url": "redis://127.0.0.1:6379/0",
"password": null
},
"api": {
"enabled": true,
"access": {
"public": false,
"whiteList": [
"127.0.0.1"
]
},
"options": {
"limits": {
"max": 0,
"delayMs": 0,
"delayAfter": 0,
"windowMs": 60000
}
}
},
"peers": {
"enabled": true,
"list": [
{
"ip": "51.15.221.205",
"port": 36666
},
{
"ip": "51.15.88.53",
"port": 36666
},
{
"ip": "5.161.68.61",
"port": 36666
},
{
"ip": "78.47.205.206",
"port": 36666
},
{
"ip": "107.161.26.184",
"port": 36666
},
{
"ip": "138.201.152.191",
"port": 36666
}
],
"access": {
"blackList": []
},
"options": {
"limits": {
"max": 0,
"delayMs": 0,
"delayAfter": 0,
"windowMs": 60000
},
"timeout": 5000
}
},
"broadcasts": {
"broadcastInterval": 1500,
"broadcastLimit": 20,
"parallelLimit": 20,
"releaseLimit": 25,
"relayLimit": 4
},
"transactions": {
"maxTxsPerQueue": 1000
},
"forging": {
"force": false,
"secret": [],
"access": {
"whiteList": [
"127.0.0.1"
]
}
},
"loading": {
"verifyOnLoading": false,
"loadPerIteration": 5000
},
"ssl": {
"enabled": false,
"options": {
"port": 443,
"address": "0.0.0.0",
"key": "./ssl/adamant.key",
"cert": "./ssl/adamant.crt"
}
},
"dapp": {
"masterrequired": true,
"masterpassword": "",
"autoexec": []
},
"wsClient": {
"portWS": 36668,
"enabled": true
},
"nethash": "bd330166898377fb28743ceef5e43a5d9d0a3efd9b3451fb7bc53530bb0a6d64"
}
12 changes: 10 additions & 2 deletions helpers/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var path = require('path');
* @param {Object} pgp - pg promise
* @param {Object} db - pg connection
*/
function Migrator (pgp, db) {
function Migrator (pgp, db, logger) {
/**
* Gets one record from `migrations` table
* @method
Expand Down Expand Up @@ -108,6 +108,10 @@ function Migrator (pgp, db) {
* @return {function} waterCb with error | appliedMigrations
*/
this.applyPendingMigrations = function (pendingMigrations, waterCb) {
if (pendingMigrations.length) {
logger.info(`Found ${pendingMigrations.length} pending migrations. Start executing, this may take a while…`);
}

var appliedMigrations = [];

async.eachSeries(pendingMigrations, function (file, eachCb) {
Expand All @@ -120,6 +124,10 @@ function Migrator (pgp, db) {
return eachCb(err);
});
}, function (err) {
if (pendingMigrations.length && !err) {
logger.info('Migrations have been successfully completed.');
}

return waterCb(err, appliedMigrations);
});
};
Expand Down Expand Up @@ -198,7 +206,7 @@ module.exports.connect = function (config, logger, cb) {
config.user = config.user || process.env.USER;

var db = pgp(config);
var migrator = new Migrator(pgp, db);
var migrator = new Migrator(pgp, db, logger);

async.waterfall([
migrator.checkMigrations,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant",
"version": "0.8.0",
"version": "0.8.1",
"private": true,
"scripts": {
"start": "node app.js",
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions tools/install_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ npm i
#Setup node: set DB password in config.json
printf "\n\nSetting node's config…\n\n"
if [[ $configfile == "config.json" ]]
then
cp default.config.json config.json
elif [ "$configfile" == "test/config.json" ]
then
cp test/config.default.json test/config.json
fi
rpl -i -q '"password": "password",' "\"password\": \"${DB_PASSWORD}\"," "$configfile"
#By default, node's API is available only from localhost
Expand Down
13 changes: 11 additions & 2 deletions tools/install_node_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ sudo dnf -y update

printf "\n\nInstalling postgresql and other prerequisites…\n\n"

sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf -qy module disable postgresql
sudo dnf -y install postgresql13 postgresql13-server postgresql13-contrib
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable --now postgresql-13
sudo dnf group install "Development Tools" -y
sudo dnf -y install wget python2 curl mc git nano automake autoconf libtool rpl wget libpq5-devel redis
sudo systemctl enable --now redis
sudo systemctl enable --now redis

#Postgres
printf "\n\nCreating database '%s' and database user '%s'…\n\n" "$databasename" "$username"
Expand Down Expand Up @@ -149,6 +149,15 @@ npm i
#Setup node: set DB password in config.json
printf "\n\nSetting node's config…\n\n"
if [[ $configfile == "config.json" ]]
then
cp default.config.json config.json
elif [ "$configfile" == "test/config.json" ]
then
cp test/config.default.json test/config.json
fi
rpl -i -q '"password": "password",' "\"password\": \"${DB_PASSWORD}\"," "$configfile"
#By default, node's API is available only from localhost
Expand Down

0 comments on commit 95df4fc

Please sign in to comment.