<p>After 2 months, I know more.</p>
<p>Formula is correct for calculating hashrate of one share.</p>

CC BY-SA 4.0
2024-02-28T18:47:58.067Z
2024-02-28T18:47:58.067Z
WebOrCode
<p>Interested in validating algorithm for calculating hashrate from stratum messages.</p>
<p>From my understanding following data is needed:<br />
<code>start_time </code>, time when miner started calculating<br />
<code>end_time</code>, time when share from miner was found<br />
<code>difficulty</code>, set by the mining pool</p>
<p>Formula for calculating hashrate(found online) is:<br />
<code>hashrate = difficulty * 2**32 / (end_time - start_time)</code></p>
<p>Example:<br />
<code>difficulty</code> is <code>131072</code> from <code>{&quot;id&quot;:null,&quot;method&quot;:&quot;mining.set_difficulty&quot;,&quot;params&quot;:[131072]}</code><br />
<code>(end_time - start_time)</code> is <code>8.844114780426025</code> from one real test example</p>
<p>Calculation:<br />
<code>131072 * 2**32 / 8.844114780426025</code><br />
<code>131072 * 4294967296 / 8.844114780426025</code><br />
<code>562949953421312 / 8.844114780426025</code><br />
Hashrate: <code>63652492917351.58</code>  or  around <code>63 Th/s</code></p>
<p>Questions:</p>
<ol>
<li>Is this correct ?</li>
<li>What is 2**32 ? (suspect that it is connected to nonce in block header)</li>
</ol>

<mining-pools><stratum>
Calculating hashrate from stratum messages
WebOrCode
# Calculating hashrate from stratum messages

(Asked by: username_0 on 2023-12-22)

Interested in validating algorithm for calculating hashrate from stratum messages.

From my understanding following data is needed:  
`start_time`, time when miner started calculating  
`end_time`, time when share from miner was found  
`difficulty`, set by the mining pool

Formula for calculating hashrate(found online) is:  
`hashrate = difficulty * 2**32 / (end_time - start_time)`

Example:  
`difficulty` is `131072` from `{"id":null,"method":"mining.set_difficulty","params":[131072]}`  
`(end_time - start_time)` is `8.844114780426025` from one real test example

Calculation:  
`131072 * 2**32 / 8.844114780426025`  
`131072 * 4294967296 / 8.844114780426025`  
`562949953421312 / 8.844114780426025`  
Hashrate: `63652492917351.58` or around `63 Th/s`

Questions:

1. Is this correct ?
2. What is 2\*\*32 ? (suspect that it is connected to nonce in block header)

**Tags:** mining-pools, stratum


---

## 1 answers

### Answer by username_0 on 2024-02-28. Score: 0 | Accepted answer

After 2 months, I know more.

Formula is correct for calculating hashrate of one share.


---

