diff --git a/init.js b/init.js index 3d4feea..1abe554 100644 --- a/init.js +++ b/init.js @@ -289,7 +289,7 @@ var spawnPoolWorkers = function(){ //var timeChangeTotal = roundTo(Math.max(now - lastStartTime, 0) / 1000, 4); if (timeChangeSec < 900) { // loyal miner keeps mining :) - redisCommands.push(['hincrbyfloat', msg.coin + ':shares:timesCurrent', workerAddress, timeChangeSec]); + redisCommands.push(['hincrbyfloat', msg.coin + ':shares:timesCurrent', workerAddress + "." + poolConfigs[msg.coin].poolId, timeChangeSec]); //logger.debug('PPLNT', msg.coin, 'Thread '+msg.thread, workerAddress+':{totalTimeSec:'+timeChangeTotal+', timeChangeSec:'+timeChangeSec+'}'); connection.multi(redisCommands).exec(function(err, replies){ if (err) diff --git a/libs/paymentProcessor.js b/libs/paymentProcessor.js index 1ba7e44..5e24b4d 100644 --- a/libs/paymentProcessor.js +++ b/libs/paymentProcessor.js @@ -908,8 +908,31 @@ function SetupForPool(logger, poolOptions, setupFinished){ logger.error(logSystem, logComponent, 'No worker shares for round: ' + round.height + ' blockHash: ' + round.blockHash); return; } - var workerTimes = allWorkerTimes[i]; - + var workerTimesWithPoolIds = allWorkerTimes[i]; + var workerTimes = {}; + var maxTime = 0; + if (pplntEnabled === true) { + for (var workerAddressWithPoolId in workerTimesWithPoolIds){ + var workerWithoutPoolId = workerAddressWithPoolId.split('.')[0]; + var workerTimeFloat = parseFloat(workerTimesWithPoolIds[workerAddressWithPoolId]); + if (maxTime < workerTimeFloat) { + maxTime = workerTimeFloat; + } + if (!(workerWithoutPoolId in workerTimes)) { + workerTimes[workerWithoutPoolId] = workerTimeFloat; + } else { + // add time from other instances with penalty + if (workerTimes[workerWithoutPoolId] < workerTimeFloat) { + workerTimes[workerWithoutPoolId] = workerTimes[workerWithoutPoolId] * 0.5 + workerTimeFloat; + } else { + workerTimes[workerWithoutPoolId] = workerTimes[workerWithoutPoolId] + workerTimeFloat * 0.5; + } + if (workerTimes[workerWithoutPoolId] > maxTime) { + workerTimes[workerWithoutPoolId] = maxTime; + } + } + } + } switch (round.category){ case 'kicked': case 'orphan': @@ -926,12 +949,6 @@ function SetupForPool(logger, poolOptions, setupFinished){ // adjust block immature .. tx fees immature = Math.round(immature - feeSatoshi); - // find most time spent in this round by single worker - maxTime = 0; - for (var workerAddress in workerTimes){ - if (maxTime < parseFloat(workerTimes[workerAddress])) - maxTime = parseFloat(workerTimes[workerAddress]); - } // total up shares for round for (var workerAddress in workerShares){ var worker = workers[workerAddress] = (workers[workerAddress] || {}); @@ -984,12 +1001,6 @@ function SetupForPool(logger, poolOptions, setupFinished){ // adjust block reward .. tx fees reward = Math.round(reward - feeSatoshi); - // find most time spent in this round by single worker - maxTime = 0; - for (var workerAddress in workerTimes){ - if (maxTime < parseFloat(workerTimes[workerAddress])) - maxTime = parseFloat(workerTimes[workerAddress]); - } // total up shares for round for (var workerAddress in workerShares){ var worker = workers[workerAddress] = (workers[workerAddress] || {}); diff --git a/libs/stats.js b/libs/stats.js index 496c49d..e2d568d 100644 --- a/libs/stats.js +++ b/libs/stats.js @@ -616,12 +616,10 @@ module.exports = function(logger, portalConfig, poolConfigs){ } for (var worker in coinStats.currentRoundTimes) { var time = parseFloat(coinStats.currentRoundTimes[worker]); - if (_maxTimeShare < time) - _maxTimeShare = time; - - var miner = worker.split(".")[0]; - if (miner in coinStats.miners) { - coinStats.miners[miner].currRoundTime += parseFloat(coinStats.currentRoundTimes[worker]); + if (_maxTimeShare < time) { _maxTimeShare = time; } + var miner = worker.split(".")[0]; // split poolId from minerAddress + if (miner in coinStats.miners && coinStats.miners[miner].currRoundTime < time) { + coinStats.miners[miner].currRoundTime = time; } } @@ -636,6 +634,10 @@ module.exports = function(logger, portalConfig, poolConfigs){ coinStats.workers[worker].luckHours = ((_networkHashRate / _wHashRate * _blocktime) / (60 * 60)).toFixed(3); coinStats.workers[worker].hashrate = _workerRate; coinStats.workers[worker].hashrateString = _this.getReadableHashRateString(_workerRate); + var miner = worker.split('.')[0]; + if (miner in coinStats.miners) { + coinStats.workers[worker].currRoundTime = coinStats.miners[miner].currRoundTime; + } } for (var miner in coinStats.miners) { var _workerRate = shareMultiplier * coinStats.miners[miner].shares / portalConfig.website.stats.hashrateWindow; diff --git a/pool_configs/zen_example.json b/pool_configs/zen_example.json index 96e8e9a..33a9662 100644 --- a/pool_configs/zen_example.json +++ b/pool_configs/zen_example.json @@ -54,6 +54,9 @@ } } }, + + "poolId": "main", + "_comment_poolId": "use it for region identification: eu, us, asia or keep default if you have one stratum instance for one coin", "daemons": [ {