Browse Source

Append \n in the sock_send function instead of adding it when constructing json in stratum.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
b86a893981
  1. 8
      util.c

8
util.c

@ -846,6 +846,7 @@ bool extract_sockaddr(struct pool *pool, char *url)
return true; return true;
} }
/* Send a single command across a socket, appending \n to it */
static bool sock_send(int sock, char *s, ssize_t len) static bool sock_send(int sock, char *s, ssize_t len)
{ {
ssize_t sent = 0; ssize_t sent = 0;
@ -853,6 +854,9 @@ static bool sock_send(int sock, char *s, ssize_t len)
if (opt_protocol) if (opt_protocol)
applog(LOG_DEBUG, "SEND: %s", s); applog(LOG_DEBUG, "SEND: %s", s);
strcat(s, "\n");
len++;
while (len > 0 ) { while (len > 0 ) {
sent = send(sock, s + sent, len, 0); sent = send(sock, s + sent, len, 0);
if (SOCKETFAIL(sent)) if (SOCKETFAIL(sent))
@ -1006,7 +1010,7 @@ bool auth_stratum(struct pool *pool)
bool ret = false; bool ret = false;
s = alloca(RECVSIZE); s = alloca(RECVSIZE);
sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}\n", sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}",
pool->swork.id++, pool->rpc_user, pool->rpc_pass); pool->swork.id++, pool->rpc_user, pool->rpc_pass);
while (sock_full(pool->sock, false)) { while (sock_full(pool->sock, false)) {
@ -1033,7 +1037,7 @@ bool initiate_stratum(struct pool *pool)
bool ret = false; bool ret = false;
s = alloca(RECVSIZE); s = alloca(RECVSIZE);
sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}\n", pool->swork.id++); sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", pool->swork.id++);
pool->sock = socket(AF_INET, SOCK_STREAM, 0); pool->sock = socket(AF_INET, SOCK_STREAM, 0);
if (pool->sock == INVSOCK) if (pool->sock == INVSOCK)

Loading…
Cancel
Save