Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Pull request Compare This branch is 5 commits ahead of jaimehgb:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
blake2
test
.gitignore
LICENSE
README.md
binding.gyp
functions.cpp
index.js
package.json
thread.js
xorshift.hpp

README.md

node-raiblocks-pow

Native compiled C Module for Node.js to calculate Proof of Work (PoW) value for a given RaiBlock Hash number (32-byte integer);

Based on jaimehgb/RaiBlocksWebAssembly, migrated to use node-gyp.

Installation

npm install --save raiblocks-pow

sync(hex)

  • hex <String> 64-character hex string of previous block hash

Generate a work value for a given block hash synchronously.

Returns 16-character hex string of work value

This is also the default function exported, you may invoke it without specifying sync:

const pow = require('raiblocks-pow');

// The following are the same:
const work1 = pow('<previous block hash>');
const work2 = pow.sync('<previous block hash>');

async(hex, callback)

  • hex <String> 64-character hex string of previous block hash
  • callback <Function> Standard error, result arguments

Generate a work value for up to 10000000 iterations.

If no valid work is found in the given iterations, the callback will be called with a string result of 0.

pow.async(hash, (error, result) => {
  console.log('Found', result);
});

threaded(hex, callback)

  • hex <String> 64-character hex string of previous block hash
  • callback <Function> Standard error, result arguments

Generate a work value until completion using multiple threads. (thread count = cpu count)

pow.threaded(hash, (error, result) => {
  console.log('Found', result);
});

Development

Use npm test to check a random block hash against an external threshold validation.

You can’t perform that action at this time.