From 525beb7379d5da8356b0e2e2f126bd258363d102 Mon Sep 17 00:00:00 2001 From: Georges Palauqui Date: Thu, 6 Jun 2024 20:08:33 +0200 Subject: [PATCH] dynamic Hashrate calculation in AxeOS (with multi chip support) --- .../src/app/components/home/home.component.ts | 16 +--------------- .../axe-os/src/app/services/system.service.ts | 2 ++ .../http_server/axe-os/src/models/ISystemInfo.ts | 2 ++ main/http_server/http_server.c | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/main/http_server/axe-os/src/app/components/home/home.component.ts b/main/http_server/axe-os/src/app/components/home/home.component.ts index 7330550c4..f3ea5177e 100644 --- a/main/http_server/axe-os/src/app/components/home/home.component.ts +++ b/main/http_server/axe-os/src/app/components/home/home.component.ts @@ -132,21 +132,7 @@ export class HomeComponent { ); this.expectedHashRate$ = this.info$.pipe(map(info => { - if (info.ASICModel === eASICModel.BM1366) { - const version = parseInt(info.boardVersion); - if (version >= 400 && version < 500) { - return Math.floor(info.frequency * ((894 * 6) / 1000)) - } else { - return Math.floor(info.frequency * (894 / 1000)) - } - } else if (info.ASICModel === eASICModel.BM1397) { - return Math.floor(info.frequency * (672 / 1000)) - } else if (info.ASICModel === eASICModel.BM1368) { - return Math.floor(info.frequency * (1276 / 1000)) - } - - return undefined; - + return Math.floor(info.frequency * ((info.coreCount * info.asicCount) / 1000)) })) this.quickLink$ = this.info$.pipe( diff --git a/main/http_server/axe-os/src/app/services/system.service.ts b/main/http_server/axe-os/src/app/services/system.service.ts index 8f0f7c41c..05be0d077 100644 --- a/main/http_server/axe-os/src/app/services/system.service.ts +++ b/main/http_server/axe-os/src/app/services/system.service.ts @@ -39,6 +39,8 @@ export class SystemService { sharesAccepted: 1, sharesRejected: 0, uptimeSeconds: 38, + asicCount: 1, + coreCount: 672, ASICModel: eASICModel.BM1366, stratumURL: "public-pool.io", stratumPort: 21496, diff --git a/main/http_server/axe-os/src/models/ISystemInfo.ts b/main/http_server/axe-os/src/models/ISystemInfo.ts index 3235e62d6..2aeb765f4 100644 --- a/main/http_server/axe-os/src/models/ISystemInfo.ts +++ b/main/http_server/axe-os/src/models/ISystemInfo.ts @@ -20,6 +20,8 @@ export interface ISystemInfo { sharesAccepted: number, sharesRejected: number, uptimeSeconds: number, + asicCount: number, + coreCount: number, ASICModel: eASICModel, stratumURL: string, stratumPort: number, diff --git a/main/http_server/http_server.c b/main/http_server/http_server.c index 57e215d8f..0ef8a8e73 100644 --- a/main/http_server/http_server.c +++ b/main/http_server/http_server.c @@ -376,6 +376,20 @@ static esp_err_t GET_system_info(httpd_req_t * req) cJSON_AddNumberToObject(root, "sharesAccepted", GLOBAL_STATE->SYSTEM_MODULE.shares_accepted); cJSON_AddNumberToObject(root, "sharesRejected", GLOBAL_STATE->SYSTEM_MODULE.shares_rejected); cJSON_AddNumberToObject(root, "uptimeSeconds", (esp_timer_get_time() - GLOBAL_STATE->SYSTEM_MODULE.start_time) / 1000000); + cJSON_AddNumberToObject(root, "asicCount", GLOBAL_STATE->asic_count); + uint16_t core_count = 0; + switch (GLOBAL_STATE->asic_model){ + case ASIC_BM1397: + core_count = BM1397_CORE_COUNT; + break; + case ASIC_BM1366: + core_count = BM1366_CORE_COUNT; + break; + case ASIC_BM1368: + core_count = BM1368_CORE_COUNT; + break; + } + cJSON_AddNumberToObject(root, "coreCount", core_count); cJSON_AddStringToObject(root, "ASICModel", GLOBAL_STATE->asic_model_str); cJSON_AddStringToObject(root, "stratumURL", stratumURL); cJSON_AddNumberToObject(root, "stratumPort", nvs_config_get_u16(NVS_CONFIG_STRATUM_PORT, CONFIG_STRATUM_PORT));