fixed overflowing 32bit us in history
This commit is contained in:
parent
4b7a6d8146
commit
eb9ad3c75a
@ -65,7 +65,9 @@ static void calculate_hashrate(history_t *history, uint32_t diff) {
|
|||||||
// add and store the newest sample
|
// add and store the newest sample
|
||||||
history->sum += diff;
|
history->sum += diff;
|
||||||
history->diffs[history->newest % ASIC_HISTORY_SIZE] = diff;
|
history->diffs[history->newest % ASIC_HISTORY_SIZE] = diff;
|
||||||
history->timestamps[history->newest % ASIC_HISTORY_SIZE] = micros();
|
|
||||||
|
// micros() wraps around after about 71.58min because it's 32bit casted from 64bit timer :facepalm:
|
||||||
|
history->timestamps[history->newest % ASIC_HISTORY_SIZE] = esp_timer_get_time();
|
||||||
|
|
||||||
uint64_t oldest_timestamp = history->timestamps[history->oldest % ASIC_HISTORY_SIZE];
|
uint64_t oldest_timestamp = history->timestamps[history->oldest % ASIC_HISTORY_SIZE];
|
||||||
uint64_t newest_timestamp = history->timestamps[history->newest % ASIC_HISTORY_SIZE];
|
uint64_t newest_timestamp = history->timestamps[history->newest % ASIC_HISTORY_SIZE];
|
||||||
|
Loading…
Reference in New Issue
Block a user