Browse Source

Pool updated for DeroKnight algo to support both ASIC and GPU mining.

master
Captain 7 months ago
parent
commit
b2d3e03640
1 changed files with 28 additions and 8 deletions
  1. +28
    -8
      lib/pool.js

+ 28
- 8
lib/pool.js View File

@@ -124,12 +124,10 @@ function BlockTemplate(template){
this.difficulty = template.difficulty;
this.height = template.height;
this.epoch = template.epoch;
this.reserveOffset =template.reserved_offset; //in the getwork


this.reserveOffset =template.reserved_offset + 1; //in the getwork
this.hashingbuffer = new Buffer(this.blockhashingblob, 'hex');
instanceId.copy(this.hashingbuffer, this.reserveOffset + 4, 0, 3);
instanceId.copy(this.hashingbuffer, this.reserveOffset + 8, 0, 4);
// instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 3);
// this.previous_hash = new Buffer(32);
// this.buffer.copy(this.previous_hash,0,7,39);
@@ -137,13 +135,27 @@ function BlockTemplate(template){
}
BlockTemplate.prototype = {
nextBlob: function(){
this.hashingbuffer.writeUInt32BE(++this.extraNonce, this.reserveOffset);

// make sure extra nonce is aligned as it should be,
buf1 = Buffer.allocUnsafe(32);
for (;;) {
this.extraNonce++;
this.hashingbuffer.writeUInt32BE(this.extraNonce, this.reserveOffset+4);
this.hashingbuffer.copy(buf1,0,this.reserveOffset, this.reserveOffset+32); // copy 32 bytes
var dividend = bignum.fromBuffer(buf1);
var remainder = dividend.mod(101);
if (remainder == 0) {
break;
}

}

this.hashingbuffer.writeUInt32BE(this.extraNonce, this.reserveOffset+4);
return this.hashingbuffer.toString('hex');
}
};



function getBlockTemplate(callback){
apiInterfaces.rpcDaemon('getblocktemplate', {reserve_size: 8, wallet_address: config.poolServer.poolAddress}, callback);
}
@@ -480,12 +492,14 @@ function processShare(miner, job, blockTemplate, nonce, resultHash){
// template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset);

//instanceId.copy(template, blockTemplate.reserveOffset + 4, 0, 3); // copy instance ID
template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset); // set extra nonce
template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset+4); // set extra nonce


nonce_buf = new Buffer(nonce, 'hex');
nonce_buf.copy(template, 39 , 0, 4);

nonce = nonce_buf.readUInt32LE(0);

//var shareBuffer = cnUtil.construct_block_blob(template, new Buffer(nonce, 'hex'));
shareBuffer = template

@@ -494,6 +508,12 @@ function processShare(miner, job, blockTemplate, nonce, resultHash){
var hash;
var shareType;

if ( nonce % 101 != 0){
//log('error', logSystem, 'nonce %d not divisible by 101',[nonce] );
log('warn', logSystem, 'Bad hash from miner %s@%s', [miner.login, miner.ip]);
return false;
}

if (shareTrustEnabled && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && Math.random() > miner.trust.probability){
hash = new Buffer(resultHash, 'hex');
shareType = 'trusted';


Loading…
Cancel
Save