Skip to content

Commit

Permalink
dynamic Hashrate calculation in AxeOS (with multi chip support)
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges760 committed Jun 7, 2024
1 parent 271d091 commit 525beb7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions main/http_server/axe-os/src/app/services/system.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions main/http_server/axe-os/src/models/ISystemInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface ISystemInfo {
sharesAccepted: number,
sharesRejected: number,
uptimeSeconds: number,
asicCount: number,
coreCount: number,
ASICModel: eASICModel,
stratumURL: string,
stratumPort: number,
Expand Down
14 changes: 14 additions & 0 deletions main/http_server/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 525beb7

Please sign in to comment.