Added txRefreshInterval

This commit is contained in:
Matt 2014-03-19 14:52:27 -06:00
parent 98d3dcc532
commit 50c8fb7c1b
3 changed files with 15 additions and 1 deletions

View File

@ -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,

View File

@ -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){

View File

@ -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