zone117x / node-stratum-pool

High performance Stratum poolserver in Node.js
GNU General Public License v2.0
419 stars 853 forks source link

vardiff is very coarse and adjusts in multiples #50

Open thunderwolf66102 opened 10 years ago

thunderwolf66102 commented 10 years ago

Vardiff seems to adjust in multiples - 8,16,32,64,128 and so on. Is there a way this can be brought down to as low as single step increments or even decimals so miner hashrate can be more accurately represented?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

zone117x commented 10 years ago

Yes vardiff needs enhanced to not only work in x2 mode. It also needs modified to support decimals (if it doesn't right now) for algos like x11. Hopefully will have time to do this at some point.

thunderwolf66102 commented 10 years ago

Branch modified that changes X2 mode to regular vdiff

b964cc211071ad99a4527be35c0eb824f9887832

zone117x commented 10 years ago

Nice work! Have you tested this out? And does it work with low-diff algos like x11? If so I'll integrate it into the main repo and have a config option for it.

thunderwolf66102 commented 10 years ago

I've tested it with a R9 270 and a single CPU miner and it worked well. However I threw my odd collection of 'miners' at it today and some were getting seemingly stranded at a high diff and one (always the same machine over multiple reattempts even though works fine with stratum-miner or original X2 diff node) so I am going to say it needs tweaked a little more yet ;)

I have been running different mods that are holding up well to actual pool use. Change multiplication to addition and the division to subtraction.

            if (avg > tMax && client.difficulty > options.minDiff) {
                ddiff = -1;
                if (ddiff + client.difficulty < options.minDiff) {
                    ddiff = options.minDiff - client.difficulty;
                }
            } else if (avg < tMin) {
                ddiff = 4;
                //var diffMax = networkDifficulty < options.maxDiff ? networkDifficulty : options.maxDiff;
                var diffMax = options.maxDiff;
                if (ddiff + client.difficulty > diffMax) {
                    ddiff = diffMax - client.difficulty;
                }
            }
            else{
                return;
            }

            var newDiff = client.difficulty + ddiff;
            timeBuffer.clear();
            _this.emit('newDifficulty', client, newDiff);
        });
    };
};
varDiff.prototype.__proto__ = events.EventEmitter.prototype;

Adjust the -1 and 4 to taste then set retarget, mindiff, maxdiff, and diff in the config file as needed. Don't leave the very bottom multiplication unchanged to addition or else you get negative difficulties and hashrates....

ghost commented 9 years ago

Bug: maxdiff will not check the values of "blockDiff" or "blockDiffActual"

        "diff": 16384,  //the pool difficulty for this port
        "varDiff": {
            "minDiff": 128, //Minimum difficulty
            "maxDiff": 6291456, //Network difficulty will be used if it is $
            "targetTime": 15, //Try to get 1 share per this many seconds
            "retargetTime": 5, //Check to see if we should retarget every t$
            "variancePercent": 30 //Allow time to very this % from target w$
        }

so if i connect 1ghash from nicehash and have a low coin with "blockDiff":35007.839338496,"blockDiffActual":0.534177236 , there are some blocks accepted with 16384 and then diffuculty jumps to 873931 .. this is way too much and we losse coins..

my aim would be to set diff = blockDiff , but this seems to be impossbile? ( as i do solo mining the number of shares is irrelevant, so just one share per block would be fine! )