stratum: add mining.set_difficulty message parse

This commit is contained in:
johnny9
2023-05-21 23:20:58 -04:00
parent 24010c3fe8
commit e246a84c86
3 changed files with 29 additions and 1 deletions

View File

@@ -114,6 +114,21 @@ stratum_method parse_stratum_method(const char * stratum_json)
return result;
}
uint32_t parse_mining_set_difficulty_message(const char * stratum_json)
{
cJSON * json = cJSON_Parse(stratum_json);
cJSON * method = cJSON_GetObjectItem(json, "method");
if (method != NULL && cJSON_IsString(method)) {
assert(strcmp("mining.set_difficulty", method->valuestring) == 0);
}
cJSON * params = cJSON_GetObjectItem(json, "params");
uint32_t difficulty = cJSON_GetArrayItem(params, 0)->valueint;
cJSON_Delete(json);
return difficulty;
}
mining_notify parse_mining_notify_message(const char * stratum_json)
{
cJSON * json = cJSON_Parse(stratum_json);