Skip to content

Firo reference stratum for testing, experimentation, and demonstration.

License

Notifications You must be signed in to change notification settings

MintPond/ref-stratum-firo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ref-stratum-firo

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 v12 and Ubuntu 16.04

Install

NodeJS v12 (Ubuntu)

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

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

Dependencies

# (ubuntu) build essentials required to compile progpow 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-firo

cd ref-stratum-firo

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

npm install

Usage

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

const Stratum = require('@mintpond/ref-stratum-firo').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: 'TC6qME2GhepR7656DgsR72pkQDmhfTDbtV', // 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: 3000, // port the stratum will listen on
        diff: 1024    // stratum difficulty
    },
    rpc: {
        host: '172.16.3.102', // Firo daemon RPC host
        port: 17001,          // Firo daemon RPC port
        user: 'rpcuser',      // Firo daemon RPC user
        password: "x"         // Firo 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 and includes founder rewards.
  • Share - Processes shares, validates proofs, creates blocks.
  • algorithm - Contains progpow constants and hash verification.

Resources