mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-04-11 13:30:51 +02:00
rervet changes - stratum messages must have unique id
This commit is contained in:
parent
b43697b9eb
commit
8755a8fcbc
@ -35,6 +35,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
|
||||
int16_t message_id;
|
||||
//Indicates the type of request the message represents.
|
||||
stratum_method method;
|
||||
|
||||
//mining.notify
|
||||
|
@ -13,6 +13,8 @@ static const char *TAG = "stratum_api";
|
||||
static char *json_rpc_buffer = NULL;
|
||||
static size_t json_rpc_buffer_size = 0;
|
||||
|
||||
// A message ID that must be unique per request that expects a response.
|
||||
// For requests not expecting a response (called notifications), this is null.
|
||||
static int send_uid = 1;
|
||||
|
||||
static void debug_stratum_tx(const char *);
|
||||
@ -115,7 +117,6 @@ 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) {
|
||||
@ -245,7 +246,7 @@ int STRATUM_V1_subscribe(int socket, char ** extranonce, int * extranonce2_len)
|
||||
{
|
||||
// Subscribe
|
||||
char subscribe_msg[BUFFER_SIZE];
|
||||
sprintf(subscribe_msg, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\"bitaxe v2.2\"]}\n", send_uid);
|
||||
sprintf(subscribe_msg, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\"bitaxe v2.2\"]}\n", send_uid++);
|
||||
debug_stratum_tx(subscribe_msg);
|
||||
write(socket, subscribe_msg, strlen(subscribe_msg));
|
||||
char * line;
|
||||
@ -263,7 +264,7 @@ int STRATUM_V1_subscribe(int socket, char ** extranonce, int * extranonce2_len)
|
||||
int STRATUM_V1_suggest_difficulty(int socket, uint32_t difficulty)
|
||||
{
|
||||
char difficulty_msg[BUFFER_SIZE];
|
||||
sprintf(difficulty_msg, "{\"id\": %d, \"method\": \"mining.suggest_difficulty\", \"params\": [%d]}\n", send_uid, difficulty);
|
||||
sprintf(difficulty_msg, "{\"id\": %d, \"method\": \"mining.suggest_difficulty\", \"params\": [%d]}\n", send_uid++, difficulty);
|
||||
debug_stratum_tx(difficulty_msg);
|
||||
write(socket, difficulty_msg, strlen(difficulty_msg));
|
||||
|
||||
@ -283,7 +284,7 @@ int STRATUM_V1_authenticate(int socket, const char * username)
|
||||
{
|
||||
char authorize_msg[BUFFER_SIZE];
|
||||
sprintf(authorize_msg, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"x\"]}\n",
|
||||
send_uid, username);
|
||||
send_uid++, username);
|
||||
debug_stratum_tx(authorize_msg);
|
||||
|
||||
write(socket, authorize_msg, strlen(authorize_msg));
|
||||
@ -296,7 +297,7 @@ void STRATUM_V1_submit_share(int socket, const char * username, const char * job
|
||||
{
|
||||
char submit_msg[BUFFER_SIZE];
|
||||
sprintf(submit_msg, "{\"id\": %d, \"method\": \"mining.submit\", \"params\": [\"%s\", \"%s\", \"%s\", \"%08x\", \"%08x\"]}\n",
|
||||
send_uid, username, jobid, extranonce_2, ntime, nonce);
|
||||
send_uid++, username, jobid, extranonce_2, ntime, nonce);
|
||||
debug_stratum_tx(submit_msg);
|
||||
write(socket, submit_msg, strlen(submit_msg));
|
||||
|
||||
@ -307,7 +308,7 @@ void STRATUM_V1_configure_version_rolling(int socket)
|
||||
{
|
||||
// Configure
|
||||
char configure_msg[BUFFER_SIZE * 2];
|
||||
sprintf(configure_msg, "{\"id\": %d, \"method\": \"mining.configure\", \"params\": [[\"version-rolling\"], {\"version-rolling.mask\": \"ffffffff\"}]}\n", send_uid);
|
||||
sprintf(configure_msg, "{\"id\": %d, \"method\": \"mining.configure\", \"params\": [[\"version-rolling\"], {\"version-rolling.mask\": \"ffffffff\"}]}\n", send_uid++);
|
||||
ESP_LOGI(TAG, "tx: %s", configure_msg);
|
||||
write(socket, configure_msg, strlen(configure_msg));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user