From 20eb6ab92e41f9a2f68cdbfe00e8894235ccd8cb Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 5 Jun 2023 13:17:20 -0400 Subject: [PATCH] accept/reject share count --- main/miner.c | 4 +++- main/system.c | 14 ++++++++++---- main/system.h | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/main/miner.c b/main/miner.c index 4557a06f..05e2b607 100755 --- a/main/miner.c +++ b/main/miner.c @@ -170,7 +170,7 @@ static void ASIC_task(void * pvParameters) //print_hex((uint8_t *)&job, sizeof(struct job_packet), sizeof(struct job_packet), "job: "); submit_share(sock, STRATUM_USER, active_jobs[nonce.job_id]->jobid, active_jobs[nonce.job_id]->ntime, active_jobs[nonce.job_id]->extranonce2, nonce.nonce); - notify_system_submitted_share(); + } } } @@ -343,8 +343,10 @@ static void stratum_task(void * pvParameters) int16_t parsed_id; if (parse_stratum_result_message(line, &parsed_id)) { ESP_LOGI(TAG, "message id %d result accepted", parsed_id); + notify_system_accepted_share(); } else { ESP_LOGI(TAG, "message id %d result rejected", parsed_id); + notify_system_rejected_share(); } } else { free(line); diff --git a/main/system.c b/main/system.c index ea30e110..dbc00f47 100644 --- a/main/system.c +++ b/main/system.c @@ -23,7 +23,8 @@ static const char *TAG = "system"; static char oled_buf[20]; static int screen_page = 0; -static int shares_submitted = 0; +static uint16_t shares_accepted = 0; +static uint16_t shares_rejected = 0; static time_t start_time; static double duration_start = 0; @@ -65,14 +66,19 @@ void update_shares(void){ } OLED_clearLine(2); memset(oled_buf, 0, 20); - snprintf(oled_buf, 20, "Shares: %i", shares_submitted); + snprintf(oled_buf, 20, "A/R: %u/%u", shares_accepted, shares_rejected); OLED_writeString(0, 2, oled_buf); } -void notify_system_submitted_share(void){ - shares_submitted++; +void notify_system_accepted_share(void){ + shares_accepted++; update_shares(); } +void notify_system_rejected_share(void){ + shares_rejected++; + update_shares(); +} + diff --git a/main/system.h b/main/system.h index 8d07fb8f..2045a378 100644 --- a/main/system.h +++ b/main/system.h @@ -4,7 +4,8 @@ void system_task(void *arg); void init_system(void); void get_stats(void); -void notify_system_submitted_share(void); +void notify_system_accepted_share(void); +void notify_system_rejected_share(void); void notify_system_found_nonce(double nonce_diff);