Do not try to generate stratum work unless the notify command has succeeded.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
diff --git a/cgminer.c b/cgminer.c
index 07a78e5..e17334f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4623,6 +4623,15 @@ static void wait_lpcurrent(struct pool *pool);
static void pool_resus(struct pool *pool);
static void gen_stratum_work(struct pool *pool, struct work *work);
+static void stratum_resumed(struct pool *pool)
+{
+ if (!pool->stratum_notify)
+ return;
+ applog(LOG_INFO, "Stratum connection to pool %d resumed", pool->pool_no);
+ pool_tclear(pool, &pool->idle);
+ pool_resus(pool);
+}
+
/* One stratum thread per pool that has stratum waits on the socket checking
* for new messages and for the integrity of the socket connection. We reset
* the connection based on the integrity of the receive side only as the send
@@ -4697,18 +4706,13 @@ static void *stratum_thread(void *userdata)
goto out;
sleep(30);
}
- applog(LOG_INFO, "Stratum connection to pool %d resumed", pool->pool_no);
- pool_tclear(pool, &pool->idle);
- pool_resus(pool);
+ stratum_resumed(pool);
continue;
}
/* Check this pool hasn't died while being a backup pool and
* has not had its idle flag cleared */
- if (pool_tclear(pool, &pool->idle)) {
- applog(LOG_INFO, "Stratum connection to pool %d resumed", pool->pool_no);
- pool_resus(pool);
- }
+ stratum_resumed(pool);
if (!parse_method(pool, s) && !parse_stratum_response(pool, s))
applog(LOG_INFO, "Unknown stratum msg: %s", s);
diff --git a/miner.h b/miner.h
index f777a30..50ed607 100644
--- a/miner.h
+++ b/miner.h
@@ -937,6 +937,7 @@ struct pool {
bool has_stratum;
bool stratum_active;
bool stratum_auth;
+ bool stratum_notify;
struct stratum_work swork;
pthread_t stratum_thread;
pthread_mutex_t stratum_lock;
diff --git a/util.c b/util.c
index 74270d5..82b1fa3 100644
--- a/util.c
+++ b/util.c
@@ -1055,13 +1055,13 @@ static char *json_array_string(json_t *val, unsigned int entry)
static bool parse_notify(struct pool *pool, json_t *val)
{
char *job_id, *prev_hash, *coinbase1, *coinbase2, *bbversion, *nbit, *ntime;
+ bool clean, ret = false;
int merkles, i;
json_t *arr;
- bool clean;
arr = json_array_get(val, 4);
if (!arr || !json_is_array(arr))
- return false;
+ goto out;
merkles = json_array_size(arr);
@@ -1090,7 +1090,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
free(nbit);
if (ntime)
free(ntime);
- return false;
+ goto out;
}
mutex_lock(&pool->pool_lock);
@@ -1137,7 +1137,9 @@ static bool parse_notify(struct pool *pool, json_t *val)
/* A notify message is the closest stratum gets to a getwork */
pool->getwork_requested++;
total_getworks++;
- return true;
+ ret = true;
+out:
+ return ret;
}
static bool parse_diff(struct pool *pool, json_t *val)
@@ -1241,8 +1243,11 @@ bool parse_method(struct pool *pool, char *s)
if (!buf)
goto out;
- if (!strncasecmp(buf, "mining.notify", 13) && parse_notify(pool, params)) {
- ret = true;
+ if (!strncasecmp(buf, "mining.notify", 13)) {
+ if (parse_notify(pool, params))
+ pool->stratum_notify = ret = true;
+ else
+ pool->stratum_notify = ret = false;
goto out;
}
@@ -1308,6 +1313,10 @@ bool auth_stratum(struct pool *pool)
goto out;
}
+
+ if (!pool->stratum_notify)
+ goto out;
+
ret = true;
applog(LOG_INFO, "Stratum authorisation success for pool %d", pool->pool_no);
pool->probed = true;