I am trying to adapt my pool based on github.com/sammy007/open-ethereum-pool to nicehash protocol.

It works more or less and I am receiving shares already, but I ran into the problem with difficulty calculation.

hasher patched for Nicehash project returns difficulty as a float64 number.

But frontend for the pool needs integer like 4000000000 to show the hashrate.

How would I convert one to another?

I tried to use the code which I found:

var pow256 = math.BigPow(2, 256
func DiffToTarget(diff float64) (target *big.Int) {
    mantissa := 0x0000ffff / diff
     exp := 1
    tmp := mantissa
    for tmp >= 256.0 {
        tmp /= 256.0
    for i := 0; i < exp; i++ {
        mantissa *= 256.0
    target = new(big.Int).Lsh(big.NewInt(int64(mantissa)), uint(26-exp)*8)

func DiffFloatToDiffInt(diffFloat float64) (diffInt *big.Int) {
    target := DiffToTarget(diffFloat)
    return new(big.Int).Div(pow256, target)

But it makes my pool show ten time more hashrate than I bought on nicehash site.

Could you please point my mistakes or point me to a place where I can find this algorithm.

  • what its the suitable diff for a private pool 20 /25 GH/s ? – mcm Aug 24 '18 at 17:00
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Ismael Aug 24 '18 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.