Browse Source

Convert uses of json_pack to JSON_CPACK in the generator

master
Con Kolivas 10 years ago
parent
commit
cfa9824b08
  1. 20
      src/generator.c

20
src/generator.c

@ -528,19 +528,19 @@ static bool subscribe_stratum(connsock_t *cs, proxy_instance_t *proxi)
retry: retry:
/* Attempt to reconnect if the pool supports resuming */ /* Attempt to reconnect if the pool supports resuming */
if (proxi->sessionid) { if (proxi->sessionid) {
req = json_pack("{s:i,s:s,s:[s,s]}", JSON_CPACK(req, "{s:i,s:s,s:[s,s]}",
"id", proxi->id++, "id", proxi->id++,
"method", "mining.subscribe", "method", "mining.subscribe",
"params", PACKAGE"/"VERSION, proxi->sessionid); "params", PACKAGE"/"VERSION, proxi->sessionid);
/* Then attempt to connect with just the client description */ /* Then attempt to connect with just the client description */
} else if (!proxi->no_params) { } else if (!proxi->no_params) {
req = json_pack("{s:i,s:s,s:[s]}", JSON_CPACK(req, "{s:i,s:s,s:[s]}",
"id", proxi->id++, "id", proxi->id++,
"method", "mining.subscribe", "method", "mining.subscribe",
"params", PACKAGE"/"VERSION); "params", PACKAGE"/"VERSION);
/* Then try without any parameters */ /* Then try without any parameters */
} else { } else {
req = json_pack("{s:i,s:s,s:[]}", JSON_CPACK(req, "{s:i,s:s,s:[]}",
"id", proxi->id++, "id", proxi->id++,
"method", "mining.subscribe", "method", "mining.subscribe",
"params"); "params");
@ -585,7 +585,7 @@ static bool passthrough_stratum(connsock_t *cs, proxy_instance_t *proxi)
json_t *req, *val = NULL, *res_val; json_t *req, *val = NULL, *res_val;
bool ret = false; bool ret = false;
req = json_pack("{s:s,s:[s]}", JSON_CPACK(req, "{s:s,s:[s]}",
"method", "mining.passthrough", "method", "mining.passthrough",
"params", PACKAGE"/"VERSION); "params", PACKAGE"/"VERSION);
ret = send_json_msg(cs, req); ret = send_json_msg(cs, req);
@ -706,7 +706,7 @@ static bool send_version(proxy_instance_t *proxi, json_t *val)
connsock_t *cs = proxi->cs; connsock_t *cs = proxi->cs;
bool ret; bool ret;
json_msg = json_pack("{sossso}", "id", id_val, "result", PACKAGE"/"VERSION, JSON_CPACK(json_msg, "{sossso}", "id", id_val, "result", PACKAGE"/"VERSION,
"error", json_null()); "error", json_null());
ret = send_json_msg(cs, json_msg); ret = send_json_msg(cs, json_msg);
json_decref(json_msg); json_decref(json_msg);
@ -869,7 +869,7 @@ static bool auth_stratum(connsock_t *cs, proxy_instance_t *proxi)
json_t *val = NULL, *res_val, *req; json_t *val = NULL, *res_val, *req;
bool ret; bool ret;
req = json_pack("{s:i,s:s,s:[s,s]}", JSON_CPACK(req, "{s:i,s:s,s:[s,s]}",
"id", proxi->id++, "id", proxi->id++,
"method", "mining.authorize", "method", "mining.authorize",
"params", proxi->auth, proxi->pass); "params", proxi->auth, proxi->pass);
@ -918,7 +918,7 @@ static void send_subscribe(proxy_instance_t *proxi, int sockd)
json_t *json_msg; json_t *json_msg;
char *msg; char *msg;
json_msg = json_pack("{sssi}", "enonce1", proxi->enonce1, JSON_CPACK(json_msg, "{sssi}", "enonce1", proxi->enonce1,
"nonce2len", proxi->nonce2len); "nonce2len", proxi->nonce2len);
msg = json_dumps(json_msg, JSON_NO_UTF8); msg = json_dumps(json_msg, JSON_NO_UTF8);
json_decref(json_msg); json_decref(json_msg);
@ -941,7 +941,7 @@ static void send_notify(proxy_instance_t *proxi, int sockd)
for (i = 0; i < ni->merkles; i++) for (i = 0; i < ni->merkles; i++)
json_array_append_new(merkle_arr, json_string(&ni->merklehash[i][0])); json_array_append_new(merkle_arr, json_string(&ni->merklehash[i][0]));
/* Use our own jobid instead of the server's one for easy lookup */ /* Use our own jobid instead of the server's one for easy lookup */
json_msg = json_pack("{sisssssssosssssssb}", JSON_CPACK(json_msg, "{sisssssssosssssssb}",
"jobid", ni->id, "prevhash", ni->prevhash, "jobid", ni->id, "prevhash", ni->prevhash,
"coinbase1", ni->coinbase1, "coinbase2", ni->coinbase2, "coinbase1", ni->coinbase1, "coinbase2", ni->coinbase2,
"merklehash", merkle_arr, "bbversion", ni->bbversion, "merklehash", merkle_arr, "bbversion", ni->bbversion,
@ -961,7 +961,7 @@ static void send_diff(proxy_instance_t *proxi, int sockd)
json_t *json_msg; json_t *json_msg;
char *msg; char *msg;
json_msg = json_pack("{sf}", "diff", proxi->diff); JSON_CPACK(json_msg, "{sf}", "diff", proxi->diff);
msg = json_dumps(json_msg, JSON_NO_UTF8); msg = json_dumps(json_msg, JSON_NO_UTF8);
json_decref(json_msg); json_decref(json_msg);
send_unix_msg(sockd, msg); send_unix_msg(sockd, msg);
@ -1161,7 +1161,7 @@ static void *proxy_send(void *arg)
mutex_unlock(&proxi->notify_lock); mutex_unlock(&proxi->notify_lock);
if (jobid) { if (jobid) {
val = json_pack("{s[ssooo]soss}", "params", proxi->auth, jobid, JSON_CPACK(val, "{s[ssooo]soss}", "params", proxi->auth, jobid,
json_object_dup(msg->json_msg, "nonce2"), json_object_dup(msg->json_msg, "nonce2"),
json_object_dup(msg->json_msg, "ntime"), json_object_dup(msg->json_msg, "ntime"),
json_object_dup(msg->json_msg, "nonce"), json_object_dup(msg->json_msg, "nonce"),

Loading…
Cancel
Save