diff --git a/lib/blockTemplate.js b/lib/blockTemplate.js index a2b17b3..eda9c96 100644 --- a/lib/blockTemplate.js +++ b/lib/blockTemplate.js @@ -9,7 +9,7 @@ var util = require('./util.js'); /** * The BlockTemplate class holds a single job. - * and provides serveral methods to validate and submit it to the daemon coin + * and provides several methods to validate and submit it to the daemon coin **/ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, publicKey, extraNoncePlaceholder){ diff --git a/lib/jobManager.js b/lib/jobManager.js index 1b25b5a..55dbfff 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -46,8 +46,8 @@ var JobCounter = function(){ /** * Emits: - * - 'newBlock'(blockTemplate) - when a new block (previously unknown to the JobManager) is being added - * - 'blockFound'(serializedBlock) - when a worker finds a block. + * - newBlock(blockTemplate) - When a new block (previously unknown to the JobManager) is added, use this event to broadcast new jobs + * - share(shareData, blockHex) - When a worker submits a share. It will have blockHex if a block was found **/ var JobManager = module.exports = function JobManager(options){ diff --git a/lib/stratum.js b/lib/stratum.js index 2ec91d8..66bc1d8 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -22,8 +22,8 @@ var SubscriptionCounter = function(){ /** * Defining each client that connects to the stratum server. * Emits: - * - 'subscription'(obj, cback(error, extraNonce1, extraNonce2Size)) - * - 'submit' FIX THIS. + * - subscription(obj, cback(error, extraNonce1, extraNonce2Size)) + * - submit(data(name, jobID, extraNonce2, ntime, nonce)) **/ var StratumClient = function(options){ diff --git a/lib/transactions.js b/lib/transactions.js index 113dfe6..0770bc2 100644 --- a/lib/transactions.js +++ b/lib/transactions.js @@ -120,9 +120,10 @@ var Generation = exports.Generation = function Generation(rpcData, publicKey, ex /* -Creating this function required tons of trial and error and reversing existing -pool server code. I went to write a good comment describing how it works in detail but -at this point I don't even know.. +This function creates the generation transaction that accepts the reward for +successfully mining a new block. Creating this function required tons of trial +and error and reversing existing pool server code. I went to write a good comment +describing how it works in detail but at this point I don't even know.. For some (probably outdated and incorrect) documentation about whats kinda going on here, see: https://en.bitcoin.it/wiki/Protocol_specification#tx diff --git a/lib/varDiff.js b/lib/varDiff.js index 63d6574..92ab1cf 100644 --- a/lib/varDiff.js +++ b/lib/varDiff.js @@ -47,6 +47,10 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){ var _this = this; + this.setNetworkDifficulty = function(diff){ + networkDifficulty = diff; + }; + if (!options.enabled){ return; } @@ -57,9 +61,7 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){ var tMin = options.targetTime - variance; var tMax = options.targetTime + variance; - this.setNetworkDifficulty = function(diff){ - networkDifficulty = diff; - }; + setInterval(function(){ _this.emit('difficultyRequest');