Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Total worker count? #456

Open
DurinsMine opened this issue Oct 13, 2018 · 2 comments
Open

Total worker count? #456

DurinsMine opened this issue Oct 13, 2018 · 2 comments

Comments

@DurinsMine
Copy link

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?

@DurinsMine
Copy link
Author

DurinsMine commented Oct 13, 2018

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?

@DurinsMine
Copy link
Author

DurinsMine commented Oct 13, 2018

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'});
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant