Total worker count?
DurinsMine opened this issue · 2 comments
Hello everyone,
Wondering if anyone knows where I can find the total of all the workers?
I have a miners and workers chart setup here https://www.durinsmine.com/#/home but I am just counting the total miners from ports page and it only seems to ever go up and not back down?
Anyone have any Ideas?
I add this to api.js
app.get('/miner/:address/identifiers/count', function (req, res) { let address = req.params.address; let ident = global.database.getCache(address + '_identifiers'); getAllWorkerStats(req.params.address, function(err, data){ if(data.global.hash <= 1){ return res.json(0); }else{ return res.json(ident.length); } }); });
I can count how many workers each address has. Now how can I get a list of all wallets with hashrates greater than 0?
app.get('/worker/count', function (req, res) {
let total_workers = 0;
let query = "SELECT payment_address FROM balance";
let response = [];
global.mysql.query(query).then(function (rows) {
if (rows.length === 0) {
return res.json("x");
}
rows.forEach(function(row){
let address = row.payment_address;
let ident = global.database.getCache(address + '_identifiers');
getAllWorkerStats(address, function(err, data){
if(data.global.hash > 1){
total_workers += ident.length;
}
});
});
return res.json(total_workers);
}).catch(function (err) {
console.error(threadName + "Error selecting wallets from balance: " + JSON.stringify(err));
return res.json({error: 'Issue getting worker data'});
});
});