Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Latest commit

 

History

History
64 lines (47 loc) · 1.35 KB

README.md

File metadata and controls

64 lines (47 loc) · 1.35 KB

Polkastats backend

Polkadot network statistics backend

This repository is ARCHIVED, for latest version go to https://github.com/polkastats/polkastats

Build backend (run as root)

# Change dir
$ cd /usr/local

# Clone this repo
$ git clone https://github.com/Colm3na/polkastats-backend.git

# Change dir
$ cd polkastats-backend

# Install dependencies
$ npm run install

# Serve with nodejs
$ node index.js

# OR start with forever (recommended)
$ forever start /usr/local/polkastats-backend/index.js

Setup backend

Setup backend MySQL database

$ mysql -u root -p'your_mysql_root_password'
> create database validators;
> use validators;
> CREATE TABLE bonded(  
   id INT NOT NULL AUTO_INCREMENT,
   accountId VARCHAR(50) NOT NULL,
   timestamp INT(8) NOT NULL,  
   amount VARCHAR(50) NOT NULL,
   PRIMARY KEY ( id )  
);
> CREATE TABLE offline (  
   id INT NOT NULL AUTO_INCREMENT,
   accountId VARCHAR(50) NOT NULL,
   blocknumber INT(8) NOT NULL,  
   times INT(8) NOT NULL,
   PRIMARY KEY ( id )  
);
> GRANT ALL PRIVILEGES ON validators.* to stats@localhost identified by 'stats';

Execute backend scripts via cron

Add this to your /etc/crontab file:

# PolkaStats backend
*/5 *  * * *   root     node /usr/local/polkastats-backend/stake.js
* *    * * *   root     node /usr/local/polkastats-backend/offline.js