Skip to content
Permalink
Browse files

Attempt stratum mining.suggest_target before mining.subscribe, if --r…

…equest-diff is used
  • Loading branch information...
luke-jr committed Aug 13, 2013
1 parent 7676509 commit 4a12eaebe60e4a085e5707ce4b4a3c67edb494dd
Showing with 29 additions and 6 deletions.
  1. +1 −0 miner.h
  2. +28 −6 util.c
@@ -845,6 +845,7 @@ struct pool;
extern bool opt_protocol;
extern bool opt_dev_protocol;
extern char *opt_coinbase_sig;
extern char *request_target_str;
extern bool have_longpoll;
extern int opt_skip_checks;
extern char *opt_kernel_path;
34 util.c
@@ -2090,6 +2090,7 @@ void suspend_stratum(struct pool *pool)
bool initiate_stratum(struct pool *pool)
{
bool ret = false, recvd = false, noresume = false, sockd = false;
bool trysuggest = request_target_str;
char s[RBUFSIZE], *sret = NULL, *nonce1, *sessionid;
json_t *val = NULL, *res_val, *err_val;
json_error_t err;
@@ -2103,9 +2104,20 @@ bool initiate_stratum(struct pool *pool)

sockd = true;

clear_sock(pool);

if (trysuggest)
{
int sz = sprintf(s, "{\"id\": null, \"method\": \"mining.suggest_target\", \"params\": [\"%s\"]}", request_target_str);
if (!_stratum_send(pool, s, sz, true))
{
applog(LOG_DEBUG, "Pool %u: Failed to send suggest_target in initiate_stratum", pool->pool_no);
goto out;
}
recvd = true;
}

if (noresume) {
/* Get rid of any crap lying around if we're resending */
clear_sock(pool);
sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++);
} else {
if (pool->sessionid)
@@ -2204,10 +2216,20 @@ bool initiate_stratum(struct pool *pool)
pool->pool_no, pool->nonce1, pool->n2size);
}
} else {
if (recvd && !noresume) {
applog(LOG_DEBUG, "Failed to resume stratum, trying afresh");
noresume = true;
goto resend;
if (recvd)
{
if (trysuggest)
{
applog(LOG_DEBUG, "Pool %u: Failed to connect stratum with mining.suggest_target, retrying without", pool->pool_no);
trysuggest = false;
goto resend;
}
if (!noresume)
{
applog(LOG_DEBUG, "Failed to resume stratum, trying afresh");
noresume = true;
goto resend;
}
}
applog(LOG_DEBUG, "Initiate stratum failed");
if (sockd)

0 comments on commit 4a12eae

Please sign in to comment.
You can’t perform that action at this time.