Commit 2fae906440cef290d4ffe73899a2c139c197f326

Con Kolivas 2012-10-03T21:10:30

Don't try to parse unneeded parameters in response to mining.subscribe.

diff --git a/miner.h b/miner.h
index 181a7e0..501badf 100644
--- a/miner.h
+++ b/miner.h
@@ -850,7 +850,6 @@ struct pool {
 	SOCKETTYPE sock;
 	struct sockaddr_in *server, client;
 	char *sockaddr_url; /* stripped url used for sockaddr */
-	char *subscription;
 	char *nonce1;
 	uint32_t nonce2;
 	int n2size;
diff --git a/util.c b/util.c
index 9b6677b..6912531 100644
--- a/util.c
+++ b/util.c
@@ -1188,11 +1188,10 @@ out:
 
 bool initiate_stratum(struct pool *pool)
 {
-	json_t *val = NULL, *res_val, *err_val, *notify_val;
-	bool ret = false, notify = false;
-	char *s, *buf, *sret = NULL;
+	json_t *val = NULL, *res_val, *err_val;
+	char *s, *sret = NULL;
 	json_error_t err;
-	int i, arr_size;
+	bool ret = false;
 
 	if (pool->stratum_active)
 		return true;
@@ -1233,8 +1232,7 @@ bool initiate_stratum(struct pool *pool)
 	err_val = json_object_get(val, "error");
 
 	if (!res_val || json_is_null(res_val) ||
-	    (err_val && !json_is_null(err_val)) ||
-	    !json_is_array(res_val)) {
+	    (err_val && !json_is_null(err_val))) {
 		char *ss;
 
 		if (err_val)
@@ -1249,32 +1247,6 @@ bool initiate_stratum(struct pool *pool)
 		goto out;
 	}
 
-	arr_size = json_array_size(res_val);
-	for (i = 0; i < arr_size; i++) {
-		notify_val = json_array_get(res_val, i);
-		if (!notify_val || json_is_null(notify_val)) {
-			applog(LOG_INFO, "Failed to parse notify_val in initiate_stratum");
-			goto out;
-		}
-
-		buf = __json_array_string(notify_val, 0);
-		if (buf && !strcasecmp(buf, "mining.notify")) {
-			notify = true;
-			break;
-		}
-	}
-
-	if (!notify) {
-		applog(LOG_INFO, "Failed to get mining notify in initiate_stratum");
-		goto out;
-	}
-
-	pool->subscription = json_array_string(notify_val, 1);
-	if (!pool->subscription) {
-		applog(LOG_INFO, "Failed to get a subscription in initiate_stratum");
-		goto out;
-	}
-
 	pool->nonce1 = json_array_string(res_val, 1);
 	if (!pool->nonce1) {
 		applog(LOG_INFO, "Failed to get nonce1 in initiate_stratum");
@@ -1296,8 +1268,8 @@ out:
 		pool->stratum_active = true;
 		pool->swork.diff = 1;
 		if (opt_protocol) {
-			applog(LOG_DEBUG, "Pool %d confirmed mining.notify with subscription %s extranonce1 %s extran2size %d",
-			       pool->pool_no, pool->subscription, pool->nonce1, pool->n2size);
+			applog(LOG_DEBUG, "Pool %d confirmed mining.subscribe with extranonce1 %s extran2size %d",
+			       pool->pool_no, pool->nonce1, pool->n2size);
 		}
 	} else
 		CLOSESOCKET(pool->sock);