mirror of https://github.com/BTCPrivate/z-nomp.git
Update shareProcessor.js
Track miner times by address not worker name
This commit is contained in:
parent
4e23d7cace
commit
0f6192e3aa
|
@ -93,17 +93,18 @@ module.exports = function(logger, poolConfig){
|
|||
if (isValidShare || isValidBlock) {
|
||||
var now = Date.now();
|
||||
var lastShareTime = now;
|
||||
if (_lastShareTimes[shareData.worker] != null && _lastShareTimes[shareData.worker] > 0)
|
||||
lastShareTime = _lastShareTimes[shareData.worker];
|
||||
var workerAddress = shareData.worker.split('.')[0];
|
||||
if (_lastShareTimes[workerAddress] != null && _lastShareTimes[workerAddress] > 0)
|
||||
lastShareTime = _lastShareTimes[workerAddress];
|
||||
|
||||
// if its been less than 10 minutes since last share was submitted
|
||||
var timeChangeSec = roundTo(Math.max(now - lastShareTime, 0) / 1000, 3);
|
||||
if (timeChangeSec < 600) {
|
||||
redisCommands.push(['hincrbyfloat', coin + ':shares:timesCurrent', shareData.worker, timeChangeSec]);
|
||||
redisCommands.push(['hincrbyfloat', coin + ':shares:timesCurrent', workerAddress, timeChangeSec]);
|
||||
}
|
||||
|
||||
|
||||
// track last time share
|
||||
_lastShareTimes[shareData.worker] = now;
|
||||
_lastShareTimes[workerAddress] = now;
|
||||
}
|
||||
|
||||
/* Stores share diff, worker, and unique value with a score that is the timestamp. Unique value ensures it
|
||||
|
@ -117,7 +118,7 @@ module.exports = function(logger, poolConfig){
|
|||
redisCommands.push(['rename', coin + ':shares:roundCurrent', coin + ':shares:round' + shareData.height]);
|
||||
redisCommands.push(['rename', coin + ':shares:timesCurrent', coin + ':shares:times' + shareData.height]);
|
||||
redisCommands.push(['sadd', coin + ':blocksPending', [shareData.blockHash, shareData.txHash, shareData.height, shareData.worker, dateNow].join(':')]);
|
||||
redisCommands.push(['hincrby', coin + ':stats', 'validBlocks', 1]);
|
||||
redisCommands.push(['hincrby', coin + ':stats', 'validBlocks', 1]);
|
||||
// reset pplnt share times for next round
|
||||
_lastShareTimes = {};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue