Skip to content

Ravencoin reference stratum for testing, experimentation, and demonstration.

License

Notifications You must be signed in to change notification settings

MintPond/ref-stratum-ravencoin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ref-stratum-ravencoin

This Reference Stratum is a simple implementation used as a basis for testing, experimentation, and demonstration purposes. It is not intended for production use.

This project has been developed and tested on Node v10.17 and Ubuntu 16.04

Install

NodeJS v10 (Ubuntu)

# Optional: uninstall current version
sudo apt-get remove node
sudo apt-get remove nodejs

# Install version 10.x
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install nodejs -y

Dependencies

# (ubuntu) build essentials required to compile KawPOW verification
sudo apt-get install build-essentials

# Dependencies may require that you have a Github personal access token to install.
npm config set @mintpond:registry https://npm.pkg.github.com/mintpond
npm config set //npm.pkg.github.com/:_authToken <PERSONAL_ACCESS_TOKEN>

Creating a personal access token

Download from Github

git clone https://github.com/MintPond/ref-stratum-ravencoin

# install
cd ref-stratum-ravencoin
npm install

Install in a Project

npm config set @mintpond:registry https://npm.pkg.github.com/mintpond
npm config set //npm.pkg.github.com/:_authToken <PERSONAL_ACCESS_TOKEN>

npm install @mintpond/ref-stratum-ravencoin --save

Usage

The stratum can be used as a module in a pool:

const Stratum = require('@mintpond/ref-stratum-ravencoin').Stratum;

class MyStratum extends Stratum {
    /* Override */
    canAuthorizeWorker(client, callback) {
        // implement your own logic
        if (client.minerAddress === 'bad') {
            // do not authorize worker
            callback(null/*error*/, false/*isAuthorized*/);
        }
        else {
            // authorize worker
            callback(null/*error*/, true/*isAuthorized*/);
        }
    }
}

const stratum = new MyStratum({
    coinbaseAddress: 'n1W99FwjX2HgBxVN9aYvpn91uhZfi9B8fj', // address that receives block reward
    blockBrand: '/@mintpond/ref-stratum/', // Branding string added to every block found
    host: "0.0.0.0", // address the stratum will listen on
    port: {
        number: 3010, // port the stratum will listen on
        diff: 10      // stratum difficulty
    },
    rpc: {
        host: '172.16.3.102', // Ravencoin daemon RPC host
        port: 17011,          // Ravencoin daemon RPC port
        user: 'rpcuser',      // Ravencoin daemon RPC user
        password: "x"         // Ravencoin daemon RPC password
    },
    jobUpdateInterval: 55,    // Broadcast job updates every n seconds
    blockPollIntervalMs: 250  // Check for new blocks every n milliseconds
});

stratum.on(Stratum.EVENT_SHARE_SUBMITTED, ev => {
    console.log(ev.share);    
});

stratum.init();

Start Script

There is a start script (start.js) included which contains further examples. It can also be run in order to get a Stratum going for test purposes. You will need to open and modify the config inside before running it.

> node start

Areas of Interest

  • ClientReader - Handles messages received from a client.
  • ClientWriter - Handles sending messages to a client.
  • Coinbase - Creates coinbase transaction.
  • Share - Processes and validates shares, creates blocks.
  • Socket - Handles binary JSON serialization and deserialization.
  • algorithm - Contains KawPOW constants and hash verification.

Resources