Check for GBT support on first probing the pool and convert to using the GBT request as the rpc request for that pool.
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
diff --git a/cgminer.c b/cgminer.c
index c681294..2055db6 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -407,7 +407,7 @@ static void sharelog(const char*disposition, const struct work*work)
static char *getwork_req = "{\"method\": \"getwork\", \"params\": [], \"id\":0}\n";
-// static char *gbt_req = "{\"id\": 0, \"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": [\"coinbasetxn\", \"workid\", \"coinbase/append\"]}]}\n";
+static char *gbt_req = "{\"id\": 0, \"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": [\"coinbasetxn\", \"workid\", \"coinbase/append\"]}]}\n";
/* Return value is ignored if not called from add_pool_details */
struct pool *add_pool(void)
@@ -4441,6 +4441,21 @@ retry_stratum:
return false;
}
+ /* Probe for GBT support on first pass */
+ if (!pool->probed && !opt_fix_protocol) {
+ applog(LOG_DEBUG, "Probing for GBT support");
+ val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass,
+ gbt_req, true, false, &rolltime, pool, false);
+ if (val) {
+ pool->has_gbt = true;
+ pool->rpc_req = gbt_req;
+ applog(LOG_DEBUG, "GBT support found, switching to GBT protocol");
+ json_decref(val);
+ } else
+ applog(LOG_DEBUG, "No GBT support found, using getwork protocol");
+ pool->probed = false;
+ }
+
gettimeofday(&tv_getwork, NULL);
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass,
pool->rpc_req, true, false, &rolltime, pool, false);
diff --git a/miner.h b/miner.h
index 85111e6..70cbfdf 100644
--- a/miner.h
+++ b/miner.h
@@ -883,6 +883,9 @@ struct pool {
struct stratum_work swork;
pthread_t stratum_thread;
pthread_mutex_t stratum_lock;
+
+ /* GBT variables */
+ bool has_gbt;
};
#define GETWORK_MODE_TESTPOOL 'T'