Bitcoin Forum

Bitcoin => Project Development => Topic started by: e4f4 on December 26, 2017, 10:20:59 AM



Title: Mining pool payout experiment
Post by: e4f4 on December 26, 2017, 10:20:59 AM
I am running a experiment on my local VM NOMP pool. Goal is to send extra payouts to workers.

Test coin -  block reward 50 coins.
Deamon wallet balance 0.
I send some coins to main deamon wallet.
Balance is 100.
When a block is found how to make NOMP combine coins already in wallet and block reward. How to make payout of 150 to worker.

Lets say payout is once in 24 hours. How to make NOMP do a payout like this:

Current wallet balance minus pending payout. That leaves extra coins. Distribute that extra coins to miners based on their submitted shares for found and confirmed blocks that day. Miners are paid like in a normal pool but they gain extra from the coins i send to pool (bought from exchange).


My guess is something needs to be changed here: https://github.com/zone117x/node-open-mining-portal/blob/master/libs/paymentProcessor.js

Maybe here:

    /* Does a batch redis call to get shares contributed to each round. Then calculates the reward
               amount owned to each miner for each round. */
            function(workers, rounds, addressAccount, callback){


                var shareLookups = rounds.map(function(r){
                    return ['hgetall', coin + ':shares:round' + r.height]
                });

                startRedisTimer();
                redisClient.multi(shareLookups).exec(function(error, allWorkerShares){
                    endRedisTimer();

                    if (error){
                        callback('Check finished - redis error with multi get rounds share');
                        return;
                    }


                    rounds.forEach(function(round, i){
                        var workerShares = allWorkerShares;

                        if (!workerShares){
                            logger.error(logSystem, logComponent, 'No worker shares for round: '
                                + round.height + ' blockHash: ' + round.blockHash);
                            return;
                        }

                        switch (round.category){
                            case 'kicked':
                            case 'orphan':
                                round.workerShares = workerShares;
                                break;

                            case 'generate':
                                /* We found a confirmed block! Now get the reward for it and calculate how much
                                   we owe each miner based on the shares they submitted during that block round. */
                                var reward = parseInt(round.reward * magnitude);

                                var totalShares = Object.keys(workerShares).reduce(function(p, c){
                                    return p + parseFloat(workerShares[c])
                                }, 0);

                                for (var workerAddress in workerShares){
                                    var percent = parseFloat(workerShares[workerAddress]) / totalShares;
                                    var workerRewardTotal = Math.floor(reward * percent);
                                    var worker = workers[workerAddress] = (workers[workerAddress] || {});
                                    worker.reward = (worker.reward || 0) + workerRewardTotal;
                                }
                                break;
                        }
                    });

                    callback(null, workers, rounds, addressAccount);
                });
            },