Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major update! Added support for FantomCoin blocks #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ var log = function(severity, system, text, data){

var cryptoNight = multiHashing['cryptonight'];

function cryptoNightFast(buf) {
return cryptoNight(Buffer.concat([new Buffer([buf.length]), buf]), true);
}

var diff1 = bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16);

var instanceId = crypto.randomBytes(4);
Expand Down Expand Up @@ -366,10 +362,10 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy
}

function processShare(miner, job, blockTemplate, nonce, resultHash){
var shareBuffer = new Buffer(blockTemplate.buffer.length);
blockTemplate.buffer.copy(shareBuffer);
shareBuffer.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset);
new Buffer(nonce, 'hex').copy(shareBuffer, 39);
var template = new Buffer(blockTemplate.buffer.length);
blockTemplate.buffer.copy(template);
template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset);
var shareBuffer = cnUtil.construct_block_blob(template, new Buffer(nonce, 'hex'));

var convertedBlob;
var hash;
Expand Down Expand Up @@ -399,7 +395,7 @@ function processShare(miner, job, blockTemplate, nonce, resultHash){
var blockFastHash;

if (hashDiff.ge(blockTemplate.difficulty)){
blockFastHash = cryptoNightFast(convertedBlob || cnUtil.convert_blob(shareBuffer)).toString('hex');
blockFastHash = cnUtil.get_block_id(shareBuffer).toString('hex');

apiInterfaces.rpcDaemon('submitblock', [shareBuffer.toString('hex')], function(error, result){
if (error){
Expand Down