Greetings!
During testing and calculating the hashrate of workers (in some bitcoin-app), we've encountered a challenge:
- The calculated hashrate of miners, based on the difficulty of the shares they submit, differs significantly (by several times) from the actual hashrate of the workers – both for ASICs and CPUMiner.
We calculate the hashrate as follows (this is pseudocode for simplicity):
```
diff = max_target / hash
total_hashes = sum(difficulty * pow(2, 32))
hash_rate = total_hashes / sec
```
Essentially, we determine the number of hashes required to find a hash of the required difficulty (`difficulty * pow(2, 32)`), and then we do this for all hashes found in the last 10 minutes, sum them up, and divide the sum by 600 seconds.
It seems like it should work.
However, in practice, CPUMiner, for example, finds shares with difficulties ranging from 0.01 to 10.0 within a 10-minute period. As a result, our formula leads to a hashrate that fluctuates wildly (by several times), deviating significantly from the actual hashrate.
Have you encountered anything similar? Could you suggest a solution or at least point us in the right direction for further investigation?
Thanks in advance to everyone who participates in this discussion.