Skip to content

Latest commit

 

History

History
93 lines (78 loc) · 3 KB

README.md

File metadata and controls

93 lines (78 loc) · 3 KB

ref-stratum-beam

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

Install

Dependencies

sudo apt-get install build-essential libboost-dev ssl-cert

# 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-beam

# install
cd ref-stratum-beam
npm install

Usage

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

const Stratum = require('@mintpond/ref-stratum-beam').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({
    host: '0.0.0.0', // address the stratum will listen on
    port: {
        number: 3025, // port the stratum will listen on
        diff: 1024,    // stratum difficulty
        // SSL
        // - these are placeholder files that may not exist or be accessible due to permissions
        // - remove these for non-SSL connection
        tlsCert: 'file:/etc/ssl/certs/ssl-cert-snakeoil.pem',
        tlsKey: 'file:/etc/ssl/private/ssl-cert-snakeoil.key'
    },
    beam: {
        host: '127.0.0.1',  // Beam node host
        port: 17021,        // Beam node port
        apiKey: 'abcd1234', // Beam node stratum API key
        useTLS: true       
    }
});

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.
  • Share - Processes shares, validates proofs.
  • algorithm - Contains BeamHash constants and hash verification.

Resources