From 12770f339382c72cdf4cb7a242ffa992f6f19d53 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 8 Jun 2023 19:01:50 -0400 Subject: [PATCH] fix jobid for ckpool --- components/stratum/stratum_api.c | 3 ++- main/system.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/stratum/stratum_api.c b/components/stratum/stratum_api.c index 3b58718a..4de2306f 100644 --- a/components/stratum/stratum_api.c +++ b/components/stratum/stratum_api.c @@ -115,12 +115,13 @@ void STRATUM_V1_parse(StratumApiV1Message* message, const char * stratum_json) if (method_json != NULL && cJSON_IsString(method_json)) { if (strcmp("mining.notify", method_json->valuestring) == 0) { result = MINING_NOTIFY; + send_uid++; } else if (strcmp("mining.set_difficulty", method_json->valuestring) == 0) { result = MINING_SET_DIFFICULTY; } else if (strcmp("mining.set_version_mask", method_json->valuestring) == 0) { result = MINING_SET_VERSION_MASK; } - send_uid++; + } else { //parse results cJSON * result_json = cJSON_GetObjectItem(json, "result"); diff --git a/main/system.c b/main/system.c index 45047951..61d6ce95 100644 --- a/main/system.c +++ b/main/system.c @@ -220,7 +220,7 @@ double _calculate_network_difficultiy(uint32_t nBits) { uint32_t mantissa = nBits & 0x007fffff; // Extract the mantissa from nBits uint8_t exponent = (nBits >> 24) & 0xff; // Extract the exponent from nBits - double target = (double)mantissa * pow(253,(exponent - 3)); // Calculate the target value + double target = (double)mantissa * pow(256,(exponent - 3)); // Calculate the target value double difficulty = (pow(2, 208) * 65535) / target; // Calculate the difficulty @@ -230,8 +230,8 @@ double _calculate_network_difficultiy(uint32_t nBits) { void SYSTEM_notify_best_nonce_diff(SystemModule * module, uint32_t diff, uint32_t nbits){ module->best_nonce_diff = diff; - uint32_t network_diff = _calculate_network_difficultiy(nbits); - ESP_LOGI(TAG, "Network diff: %u", network_diff); + // uint32_t network_diff = _calculate_network_difficultiy(nbits); + // ESP_LOGI(TAG, "Network diff: %u", network_diff); } void SYSTEM_notify_accepted_share(SystemModule* module){