mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-20 05:48:35 +02:00
Setting the new sizes, holders, and test states to see if this thing works.
This commit is contained in:
+36
-2
@@ -69,7 +69,7 @@ function Coin(data){
|
||||
|
||||
this.getBlockTemplate = function(walletAddress, callback){
|
||||
global.support.rpcDaemon('getblocktemplate', {
|
||||
reserve_size: 8,
|
||||
reserve_size: 16,
|
||||
wallet_address: walletAddress
|
||||
}, function(body){
|
||||
return callback(body);
|
||||
@@ -102,22 +102,56 @@ function Coin(data){
|
||||
};
|
||||
|
||||
this.BlockTemplate = function(template) {
|
||||
/*
|
||||
Generating a block template is a simple thing. Ask for a boatload of information, and go from there.
|
||||
Important things to consider.
|
||||
The reserved space is 13 bytes long now in the following format:
|
||||
|minerNonce/extraNonce - 4 bytes|instanceId - 4 bytes|clientNonce - 4 bytes|clientPoolNonce - 4 bytes|
|
||||
This is designed to allow a single block template to be used on up to 4 billion poolSlaves (clientPoolNonce)
|
||||
Each with 4 billion clients. (clientNonce)
|
||||
While being unique to this particular pool thread (instanceId)
|
||||
With up to 4 billion clients (minerNonce/extraNonce)
|
||||
Overkill? Sure. But that's what we do here. Overkill.
|
||||
*/
|
||||
|
||||
// Set this.blob equal to the BT blob that we get from upstream.
|
||||
this.blob = template.blocktemplate_blob;
|
||||
// Set this.diff equal to the known diff for this block.
|
||||
this.difficulty = template.difficulty;
|
||||
// Set this.height equal to the known height for this block.
|
||||
this.height = template.height;
|
||||
// Set this.reserveOffset to the byte location of the reserved offset.
|
||||
this.reserveOffset = template.reserved_offset;
|
||||
// Set this.buffer to the binary decoded version of the BT blob.
|
||||
this.buffer = new Buffer(this.blob, 'hex');
|
||||
// Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes.
|
||||
instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 3);
|
||||
// Generate a clean, shiny new buffer.
|
||||
this.previous_hash = new Buffer(32);
|
||||
// Copy in bytes 7 through 39 to this.previous_hash from the current BT.
|
||||
this.buffer.copy(this.previous_hash, 0, 7, 39);
|
||||
// Reset the Nonce. - This is the per-miner/pool nonce
|
||||
this.extraNonce = 0;
|
||||
// The clientNonceLocation is the location at which the client pools should set the nonces for each of their clients.
|
||||
this.clientNonceLocation = this.reserveOffset + 8;
|
||||
// The clientPoolLocation is for multi-thread/multi-server pools to handle the nonce for each of their tiers.
|
||||
this.clientPoolLocation = this.reserveOffset + 12;
|
||||
this.nextBlob = function () {
|
||||
// Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset.
|
||||
this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset);
|
||||
// Convert the blob into something hashable.
|
||||
return global.coinFuncs.convertBlob(this.buffer).toString('hex');
|
||||
};
|
||||
// Make it so you can get the raw block blob out.
|
||||
this.nextBlobWithChildNonce = function () {
|
||||
// Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset.
|
||||
this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset);
|
||||
// Don't convert the blob to something hashable. You bad.
|
||||
return this.buffer.toString('hex');
|
||||
};
|
||||
};
|
||||
|
||||
this.cryptoNight = multiHashing['cryptonight'];
|
||||
this.cryptoNight = multiHashing.cryptoNight;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user