feat(miner): scale displayed hashrate units dynamically

This commit is contained in:
2026-03-30 11:47:36 +02:00
parent b6af554b0c
commit 7f217df04f
4 changed files with 59 additions and 5 deletions

View File

@@ -53,6 +53,7 @@ static void emit_eventf(int fd, const char *fmt, ...) {
static void status_callback(long long attempts, double hashrate_hz, void *ctx_ptr) {
StatusCtx *ctx = (StatusCtx *)ctx_ptr;
char rate_buf[32];
if (ctx->event_fd >= 0) {
emit_eventf(ctx->event_fd, "status %d %.6f %lld\n", ctx->worker_idx, hashrate_hz / 1000.0, attempts);
@@ -60,7 +61,8 @@ static void status_callback(long long attempts, double hashrate_hz, void *ctx_pt
}
if (ctx->single_mode) {
printf("\r[main] hashrate: %.2f kH/s | attempts: %lld", hashrate_hz / 1000.0, attempts);
format_hashrate_hz(hashrate_hz, rate_buf, sizeof(rate_buf));
printf("\r[main] hashrate: %s | attempts: %lld", rate_buf, attempts);
fflush(stdout);
}
}