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

Colm3na/polkastats-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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