diff --git a/README.md b/README.md index f0f3bce..8bb49a5 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,11 @@ var pool = Stratum.createPool({ "address": "mi4iBXbBsydtcc5yFmsff2zCFVX4XG7qJc", //Address to where block rewards are given "blockRefreshInterval": 1000, //How often to poll RPC daemons for new blocks, in milliseconds + + /* How many milliseconds should have passed before new block transactions will trigger a new + job broadcast. */ + "txRefreshInterval": 20000, + //instanceId: 37, //Recommend not using this because a crypto-random one will be generated /* Some attackers will create thousands of workers that use up all available socket connections, diff --git a/lib/jobManager.js b/lib/jobManager.js index 342d120..af0d73b 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -132,6 +132,8 @@ var JobManager = module.exports = function JobManager(options){ this.currentJob; this.validJobs = {}; + var lastTransactionUpdateCheck = Date.now(); + //returns true if processed a new block this.processTemplate = function(rpcData, publicKey){ @@ -151,6 +153,12 @@ var JobManager = module.exports = function JobManager(options){ (_this.currentJob.rpcData.transactions.length != rpcData.transactions.length) + if (updatedTransactions && (Date.now() - lastTransactionUpdateCheck >= options.txRefreshInterval)){ + lastTransactionUpdateCheck = Date.now(); + } + else + updatedTransactions = false; + //Update current job if new block or new transactions if (isNewBlock || updatedTransactions){ diff --git a/lib/pool.js b/lib/pool.js index 3ea61ca..953c366 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -123,7 +123,8 @@ var pool = module.exports = function pool(options, authorizeFn){ address : options.address, algorithm : options.coin.algorithm, reward : options.coin.reward, - txMessages: options.coin.txMessages + txMessages: options.coin.txMessages, + txRefreshInterval: options.txRefreshInterval }); _this.jobManager.on('newBlock', function(blockTemplate){ //Check if stratumServer has been initialized yet