PPLNT fix for multiple instances.

This commit is contained in:
Konstantin Crutched Anikin 2018-03-02 13:01:28 +07:00
parent 53e9fdb28a
commit ed76b45f4b
4 changed files with 37 additions and 21 deletions

View File

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

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

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

View File

@ -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": [
{