Permalink
Browse files

PPLNT fix for multiple instances.

  • Loading branch information...
crutched committed Mar 2, 2018
1 parent 53e9fdb commit ed76b45f4b58efb75fc0a3b996f8dd86f0d87dae
Showing with 37 additions and 21 deletions.
  1. +1 −1 init.js
  2. +25 −14 libs/paymentProcessor.js
  3. +8 −6 libs/stats.js
  4. +3 −0 pool_configs/zen_example.json
View
@@ -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)
View
@@ -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] || {});
View
@@ -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;
@@ -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": [
{

0 comments on commit ed76b45

Please sign in to comment.