mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-18 05:42:16 +01:00
add best difficulty since system boot (#162)
This commit is contained in:
parent
e4fcfdca83
commit
afd4a30985
@ -68,13 +68,17 @@
|
||||
<div class="flex justify-content-between mb-3">
|
||||
<div>
|
||||
<span class="block text-500 font-medium mb-3">Best Difficulty</span>
|
||||
<div class="text-900 font-medium text-xl">{{info.bestDiff}}</div>
|
||||
<div class="text-900 font-medium text-xl">{{info.bestDiff}}
|
||||
<span class="text-500">all-time best</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex align-items-center justify-content-center bg-yellow-100 border-round"
|
||||
[ngStyle]="{width: '2.5rem', height: '2.5rem'}">
|
||||
<i class="pi pi-star-fill text-yellow-500 text-xl"></i>
|
||||
</div>
|
||||
</div>
|
||||
<span class="text-900 font-medium">{{info.bestSessionDiff}} </span>
|
||||
<span class="text-500">since system boot</span>
|
||||
<!-- <span class="text-green-500 font-medium">520 </span>
|
||||
<span class="text-500">newly registered</span> -->
|
||||
</div>
|
||||
|
@ -28,6 +28,7 @@ export class SystemService {
|
||||
temp: 60,
|
||||
hashRate: 475,
|
||||
bestDiff: "0",
|
||||
bestSessionDiff: "0",
|
||||
freeHeap: 200504,
|
||||
coreVoltage: 1200,
|
||||
coreVoltageActual: 1200,
|
||||
|
@ -11,6 +11,7 @@ export interface ISystemInfo {
|
||||
temp: number,
|
||||
hashRate: number,
|
||||
bestDiff: string,
|
||||
bestSessionDiff: string,
|
||||
freeHeap: number,
|
||||
coreVoltage: number,
|
||||
hostname: string,
|
||||
|
@ -354,6 +354,7 @@ static esp_err_t GET_system_info(httpd_req_t * req)
|
||||
cJSON_AddNumberToObject(root, "temp", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.chip_temp);
|
||||
cJSON_AddNumberToObject(root, "hashRate", GLOBAL_STATE->SYSTEM_MODULE.current_hashrate);
|
||||
cJSON_AddStringToObject(root, "bestDiff", GLOBAL_STATE->SYSTEM_MODULE.best_diff_string);
|
||||
cJSON_AddStringToObject(root, "bestSessionDiff", GLOBAL_STATE->SYSTEM_MODULE.best_session_diff_string);
|
||||
|
||||
cJSON_AddNumberToObject(root, "freeHeap", esp_get_free_heap_size());
|
||||
cJSON_AddNumberToObject(root, "coreVoltage", nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE));
|
||||
|
@ -44,6 +44,7 @@ static void _init_system(GlobalState * global_state, SystemModule * module)
|
||||
module->shares_accepted = 0;
|
||||
module->shares_rejected = 0;
|
||||
module->best_nonce_diff = nvs_config_get_u64(NVS_CONFIG_BEST_DIFF, 0);
|
||||
module->best_session_nonce_diff = 0;
|
||||
module->start_time = esp_timer_get_time();
|
||||
module->lastClockSync = 0;
|
||||
module->FOUND_BLOCK = false;
|
||||
@ -57,6 +58,7 @@ static void _init_system(GlobalState * global_state, SystemModule * module)
|
||||
|
||||
// set the best diff string
|
||||
_suffix_string(module->best_nonce_diff, module->best_diff_string, DIFF_STRING_SIZE, 0);
|
||||
_suffix_string(module->best_session_nonce_diff, module->best_session_diff_string, DIFF_STRING_SIZE, 0);
|
||||
|
||||
// set the ssid string to blank
|
||||
memset(module->ssid, 0, 20);
|
||||
@ -269,6 +271,11 @@ static double _calculate_network_difficulty(uint32_t nBits)
|
||||
|
||||
static void _check_for_best_diff(SystemModule * module, double diff, uint32_t nbits)
|
||||
{
|
||||
if ((uint64_t) diff > module->best_session_nonce_diff) {
|
||||
module->best_session_nonce_diff = (uint64_t) diff;
|
||||
_suffix_string((uint64_t) diff, module->best_session_diff_string, DIFF_STRING_SIZE, 0);
|
||||
}
|
||||
|
||||
if ((uint64_t) diff <= module->best_nonce_diff) {
|
||||
return;
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ typedef struct
|
||||
char oled_buf[20];
|
||||
uint64_t best_nonce_diff;
|
||||
char best_diff_string[DIFF_STRING_SIZE];
|
||||
uint64_t best_session_nonce_diff;
|
||||
char best_session_diff_string[DIFF_STRING_SIZE];
|
||||
bool FOUND_BLOCK;
|
||||
bool startup_done;
|
||||
char ssid[20];
|
||||
|
Loading…
x
Reference in New Issue
Block a user