Browse Source

Selectively compact json that does not need to be visualised

master
Con Kolivas 9 years ago
parent
commit
25aecd33c8
  1. 10
      src/connector.c
  2. 4
      src/stratifier.c

10
src/connector.c

@ -344,7 +344,7 @@ static void generator_drop_client(ckpool_t *ckp, const client_instance_t *client
JSON_CPACK(val, "{si,sI:ss:si:ss:s[]}", "id", 42, "client_id", client->id, "address", JSON_CPACK(val, "{si,sI:ss:si:ss:s[]}", "id", 42, "client_id", client->id, "address",
client->address_name, "server", client->server, "method", "mining.term", client->address_name, "server", client->server, "method", "mining.term",
"params"); "params");
s = json_dumps(val, 0); s = json_dumps(val, JSON_COMPACT);
json_decref(val); json_decref(val);
send_proc(ckp->generator, s); send_proc(ckp->generator, s);
free(s); free(s);
@ -520,7 +520,7 @@ reparse:
json_object_set_new_nocheck(val, "address", json_string(client->address_name)); json_object_set_new_nocheck(val, "address", json_string(client->address_name));
} }
json_object_set_new_nocheck(val, "server", json_integer(client->server)); json_object_set_new_nocheck(val, "server", json_integer(client->server));
s = json_dumps(val, 0); s = json_dumps(val, JSON_COMPACT);
/* Do not send messages of clients we've already dropped. We /* Do not send messages of clients we've already dropped. We
* do this unlocked as the occasional false negative can be * do this unlocked as the occasional false negative can be
@ -800,7 +800,7 @@ static void redirect_client(ckpool_t *ckp, client_instance_t *client)
num = add_redirect(ckp, cdata, client); num = add_redirect(ckp, cdata, client);
JSON_CPACK(val, "{sosss[ssi]}", "id", json_null(), "method", "client.reconnect", JSON_CPACK(val, "{sosss[ssi]}", "id", json_null(), "method", "client.reconnect",
"params", ckp->redirecturl[num], ckp->redirectport[num], 0); "params", ckp->redirecturl[num], ckp->redirectport[num], 0);
buf = json_dumps(val, JSON_EOL); buf = json_dumps(val, JSON_EOL | JSON_COMPACT);
json_decref(val); json_decref(val);
sender_send = ckzalloc(sizeof(sender_send_t)); sender_send = ckzalloc(sizeof(sender_send_t));
@ -935,7 +935,7 @@ static void send_client(cdata_t *cdata, const int64_t id, char *buf)
json_object_set_new_nocheck(val, "client_id", json_integer(client->id)); json_object_set_new_nocheck(val, "client_id", json_integer(client->id));
json_object_set_new_nocheck(val, "address", json_string(client->address_name)); json_object_set_new_nocheck(val, "address", json_string(client->address_name));
json_object_set_new_nocheck(val, "server", json_integer(client->server)); json_object_set_new_nocheck(val, "server", json_integer(client->server));
msg = json_dumps(val, 0); msg = json_dumps(val, JSON_COMPACT);
json_decref(val); json_decref(val);
send_proc(ckp->stratifier, msg); send_proc(ckp->stratifier, msg);
free(msg); free(msg);
@ -997,7 +997,7 @@ static void process_client_msg(cdata_t *cdata, const char *buf)
if (client_id > 0xffffffffll) if (client_id > 0xffffffffll)
json_object_set_new_nocheck(json_msg, "client_id", json_integer(client_id & 0xffffffffll)); json_object_set_new_nocheck(json_msg, "client_id", json_integer(client_id & 0xffffffffll));
msg = json_dumps(json_msg, JSON_EOL); msg = json_dumps(json_msg, JSON_EOL | JSON_COMPACT);
send_client(cdata, client_id, msg); send_client(cdata, client_id, msg);
json_decref(json_msg); json_decref(json_msg);
} }

4
src/stratifier.c

@ -4740,7 +4740,7 @@ static void submit_share(stratum_instance_t *client, const int64_t jobid, const
JSON_CPACK(json_msg, "{sIsssssssIsIsi}", "jobid", jobid, "nonce2", enonce2, JSON_CPACK(json_msg, "{sIsssssssIsIsi}", "jobid", jobid, "nonce2", enonce2,
"ntime", ntime, "nonce", nonce, "client_id", client->id, "ntime", ntime, "nonce", nonce, "client_id", client->id,
"proxy", client->proxyid, "subproxy", client->subproxyid); "proxy", client->proxyid, "subproxy", client->subproxyid);
msg = json_dumps(json_msg, 0); msg = json_dumps(json_msg, JSON_COMPACT);
json_decref(json_msg); json_decref(json_msg);
send_generator(ckp, msg, GEN_LAX); send_generator(ckp, msg, GEN_LAX);
free(msg); free(msg);
@ -5571,7 +5571,7 @@ static void ssend_process(ckpool_t *ckp, smsg_t *msg)
/* Add client_id to the json message and send it to the /* Add client_id to the json message and send it to the
* connector process to be delivered */ * connector process to be delivered */
json_object_set_new_nocheck(msg->json_msg, "client_id", json_integer(msg->client_id)); json_object_set_new_nocheck(msg->json_msg, "client_id", json_integer(msg->client_id));
s = json_dumps(msg->json_msg, 0); s = json_dumps(msg->json_msg, JSON_COMPACT);
send_proc(ckp->connector, s); send_proc(ckp->connector, s);
free(s); free(s);
free_smsg(msg); free_smsg(msg);

Loading…
Cancel
Save