Author

Topic: Calculating hashrate (Read 117 times)

newbie
Activity: 1
Merit: 0
March 13, 2018, 04:06:33 AM
#1
I am trying to implement calculation of hashrate for the ellaism pool.

My task is supporting NiceHash algorith

There is specification https://github.com/nicehash/Specifications/blob/master/EthereumStratum_NiceHash_v1.0.0.txt
some excerpt:
Quote
First item of params array is difficulty in double data type. Conversion
between difficulty and target is done the same way as with Bitcoin;
difficulty of 1 is transformed to target being in HEX:
00000000ffff0000000000000000000000000000000000000000000000000000

From my go/ethash code, I am receiving difficulty as a float value, like
shareDiffFloat=1.6744196933074476
shareDiffFloat=4.889094872076708
or
shareDiffFloat=0.914777543972353

I am googled and found code that transforms that into uint64 (what my pool stats mechanism expects)
 
it's like:
Code:
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
        exp++
    }
    for i := 0; i < exp; i++ {
        mantissa *= 256.0
    }
    target = new(big.Int).Lsh(big.NewInt(int64(mantissa)), uint(26-exp)*8)
    return
}

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

then shareDiff := shareDiff_big.Int64()

but it seems incorrect.

I always receive ten (or more) times more hashrate than I have.

When my miners report about 1 GH, I get 12Ghs or more in my stats front-end.

 
I've read somewhere in nicehash forums some examples, like
> 0.93130836 equals 4000000000 int diff

But I don't understand this algorithms.

Could someone please point me to right paper about that, or even better verify this code above?
Jump to: