BugFix, solo/prop status not displaying

This commit is contained in:
muscleman 2022-01-26 09:08:58 -06:00
parent cfcecdd3f7
commit fffb26c141
7 changed files with 1942 additions and 1065 deletions

View file

@ -117,6 +117,7 @@
"interval": 60,
"depth": 10,
"poolFee": 0.2,
"soloFee": 0.2,
"devDonation": 0.5,
"networkFee": 0.0
},

View file

@ -117,6 +117,7 @@
"interval": 60,
"depth": 10,
"poolFee": 0.2,
"soloFee": 0.2,
"devDonation": 0.5,
"networkFee": 0.0
},

View file

@ -378,6 +378,7 @@ function collectStats(){
cnBlobType: config.cnBlobType || 0,
hashrateWindow: config.api.hashrateWindow,
fee: config.blockUnlocker.poolFee,
soloFee: config.blockUnlocker.soloFee >= 0 ? config.blockUnlocker.soloFee : (config.blockUnlocker.poolFee > 0 ? config.blockUnlocker.poolFee : 0),
networkFee: config.blockUnlocker.networkFee || 0,
coin: config.coin,
coinUnits: config.coinUnits,

View file

@ -218,7 +218,10 @@ function runInterval(){
block.reward
].join(':')])
let feePercent = config.blockUnlocker.poolFee / 100
let feePercent = (config.blockUnlocker.poolFee > 0 ? config.blockUnlocker.poolFee : 0) / 100
if (block.rewardType === 'solo')
feePercent = (config.blockUnlocker.soloFee >= 0 ? config.blockUnlocker.soloFee : (config.blockUnlocker.poolFee > 0 ? config.blockUnlocker.poolFee : 0)) / 100
if (Object.keys(donations).length) {
for(let wallet in donations) {

View file

@ -77,6 +77,17 @@ let statValueHandler = {
}
};
let preSaveFunctions = {
hashrate: statValueHandler.avgRound,
hashrateSolo: statValueHandler.avgRound,
workers: statValueHandler.max,
workersSolo: statValueHandler.max,
difficulty: statValueHandler.avgRound,
price: statValueHandler.avg,
profit: statValueHandler.avg
};
/*
// Presave functions
let preSaveFunctions = {
hashrate: statValueHandler.avgRound,
@ -85,14 +96,49 @@ let preSaveFunctions = {
price: statValueHandler.avg,
profit: statValueHandler.avg
};
*/
// Store collected values in redis database
function storeCollectedValues(chartName, values, settings) {
for(let i in values) {
storeCollectedValue(chartName + ':' + i, values[i], settings);
storeCollectedValue(chartName + ':' + i, [values[i]], settings);
}
}
function storeCollectedValue (chartName, values, settings) {
let now = new Date() / 1000 | 0;
values.forEach((value, index) => {
let name = `${chartName}` + (index === 0 ? '' : 'Solo')
return getChartDataFromRedis(name, function (sets) {
let lastSet = sets[sets.length - 1]; // [time, avgValue, updatesCount]
if (!lastSet || now - lastSet[0] > settings.stepInterval) {
lastSet = [now, value, 1];
sets.push(lastSet);
while (now - sets[0][0] > settings.maximumPeriod) { // clear old sets
sets.shift();
}
} else {
preSaveFunctions[name] ?
preSaveFunctions[name](lastSet, value) :
statValueHandler.avgRound(lastSet, value);
lastSet[2]++;
}
if (getStatsRedisKey(name)
.search(`^${config.coin}:charts:hashrate$`) >= 0) {
redisClient.set(getStatsRedisKey(name), JSON.stringify(sets), 'EX', (86400 * cleanupInterval));
} else if (getStatsRedisKey(name)
.search(`^${config.coin}:charts:hashrateSolo$`) >= 0) {
redisClient.set(getStatsRedisKey(name), JSON.stringify(sets), 'EX', (86400 * cleanupInterval));
} else {
redisClient.set(getStatsRedisKey(name), JSON.stringify(sets));
}
log('info', logSystem, name + ' chart collected value ' + value + '. Total sets count ' + sets.length);
});
})
}
/*
// Store collected value in redis database
function storeCollectedValue(chartName, value, settings) {
let now = new Date() / 1000 | 0;
@ -122,6 +168,7 @@ function storeCollectedValue(chartName, value, settings) {
log('info', logSystem, chartName + ' chart collected value ' + value + '. Total sets count ' + sets.length);
});
}
*/
// Collect pool statistics with an interval
function collectPoolStatWithInterval(chartName, settings) {
@ -166,7 +213,7 @@ function getPoolStats(callback) {
**/
function getPoolHashrate(callback) {
getPoolStats(function(error, stats) {
callback(error, stats.pool ? Math.round(stats.pool.hashrate) : null);
callback(error, stats.pool ? [Math.round(stats.pool.hashrate), Math.round(stats.pool.hashrateSolo)] : null);
});
}
@ -175,7 +222,7 @@ function getPoolHashrate(callback) {
**/
function getPoolMiners(callback) {
getPoolStats(function(error, stats) {
callback(error, stats.pool ? stats.pool.miners : null);
callback(error, stats.pool ? [stats.pool.miners, stats.pool.minersSolo] : null);
});
}
@ -184,7 +231,7 @@ function getPoolMiners(callback) {
**/
function getPoolWorkers(callback) {
getPoolStats(function(error, stats) {
callback(error, stats.pool ? stats.pool.workers : null);
callback(error, stats.pool ? [stats.pool.workers, stats.pool.workersSolo] : null);
});
}
@ -193,7 +240,7 @@ function getPoolWorkers(callback) {
**/
function getNetworkDifficulty(callback) {
getPoolStats(function(error, stats) {
callback(error, stats.pool ? stats.network.difficulty : null);
callback(error, stats.pool ? [stats.network.difficulty] : null);
});
}
@ -327,6 +374,12 @@ function getPoolChartsData(callback) {
redisKeys.push(getStatsRedisKey(chartName));
}
}
chartsNames.push('hashrateSolo')
chartsNames.push('minersSolo')
chartsNames.push('workersSolo')
redisKeys.push(getStatsRedisKey('hashrateSolo'))
redisKeys.push(getStatsRedisKey('minersSolo'))
redisKeys.push(getStatsRedisKey('workersSolo'))
if(redisKeys.length) {
redisClient.mget(redisKeys, function(error, data) {
let stats = {};

View file

@ -1007,6 +1007,26 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy
redisCommands.push(['hset', `${coin}:unique_workers:${login}~${workerName}`, 'lastShare', dateNowSeconds]);
redisCommands.push(['expire', `${coin}:unique_workers:${login}~${workerName}`, (86400 * cleanupInterval)]);
}
/*
if (blockCandidate){
redisCommands.push(['hset', `${coin}:stats`, `lastBlockFound${rewardType}`, Date.now()]);
redisCommands.push(['rename', `${coin}:scores:prop:roundCurrent`, coin + ':scores:prop:round' + job_height]);
redisCommands.push(['rename', `${coin}:scores:solo:roundCurrent`, coin + ':scores:solo:round' + job_height]);
redisCommands.push(['rename', `${coin}:shares_actual:prop:roundCurrent`, `${coin}:shares_actual:prop:round${job_height}`]);
redisCommands.push(['rename', `${coin}:shares_actual:solo:roundCurrent`, `${coin}:shares_actual:solo:round${job_height}`]);
if (rewardType === 'prop') {
redisCommands.push(['hgetall', `${coin}:scores:prop:round${job_height}`]);
redisCommands.push(['hgetall', `${coin}:shares_actual:prop:round${job_height}`]);
}
if (rewardType === 'solo') {
redisCommands.push(['hget', `${coin}:scores:solo:round${job_height}`, login]);
redisCommands.push(['hget', `${coin}:shares_actual:solo:round${job_height}`, login]);
}
}
*/
if (blockCandidate){
redisCommands.push(['hset', `${coin}:stats`, `lastBlockFound${rewardType}`, Date.now()]);

File diff suppressed because it is too large Load diff