From 5aa50a421571104d9fac5228c10e8fcbb579c9fb Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Thu, 13 Jul 2017 19:39:47 +0200 Subject: [PATCH] equihash: use client.show_message to get block height current stratum is imcomplete and doesnt provide the coinbase data --- ccminer.vcxproj | 3 ++- equi/equi-stratum.cpp | 32 ++++++++++++++++++++++++++++++++ miner.h | 1 + util.cpp | 3 +++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/ccminer.vcxproj b/ccminer.vcxproj index 8df2652..552c595 100644 --- a/ccminer.vcxproj +++ b/ccminer.vcxproj @@ -297,6 +297,7 @@ compute_52,sm_52;compute_50,sm_50;compute_30,sm_30 -Xptxas -dlcm=ca -Xptxas -dscm=cs %(AdditionalOptions) 0 + compute_61,sm_61;compute_52,sm_52;compute_50,sm_50;compute_30,sm_30 160 @@ -599,4 +600,4 @@ - + diff --git a/equi/equi-stratum.cpp b/equi/equi-stratum.cpp index c9f6587..83e67ab 100644 --- a/equi/equi-stratum.cpp +++ b/equi/equi-stratum.cpp @@ -185,6 +185,38 @@ out: return ret; } +// equihash stratum protocol is not standard, use client.show_message to pass block height +bool equi_stratum_show_message(struct stratum_ctx *sctx, json_t *id, json_t *params) +{ + char *s; + json_t *val; + bool ret; + + val = json_array_get(params, 0); + if (val) { + const char* data = json_string_value(val); + if (data && strlen(data)) { + char symbol[32] = { 0 }; + int ss = sscanf(data, "equihash %s block %u", symbol, &sctx->job.height); + if (opt_debug && ss > 1) applog(LOG_DEBUG, "%s", data); + } + } + + if (!id || json_is_null(id)) + return true; + + val = json_object(); + json_object_set(val, "id", id); + json_object_set_new(val, "error", json_null()); + json_object_set_new(val, "result", json_true()); + s = json_dumps(val, 0); + ret = stratum_send_line(sctx, s); + json_decref(val); + free(s); + + return ret; +} + void equi_store_work_solution(struct work* work, uint32_t* hash, void* sol_data) { int nonce = work->valid_nonces-1; diff --git a/miner.h b/miner.h index 492b6a9..f3406dd 100644 --- a/miner.h +++ b/miner.h @@ -815,6 +815,7 @@ bool rpc2_stratum_authorize(struct stratum_ctx *sctx, const char *user, const ch bool equi_stratum_notify(struct stratum_ctx *sctx, json_t *params); bool equi_stratum_set_target(struct stratum_ctx *sctx, json_t *params); bool equi_stratum_submit(struct pool_infos *pool, struct work *work); +bool equi_stratum_show_message(struct stratum_ctx *sctx, json_t *id, json_t *params); void equi_work_set_target(struct work* work, double diff); void equi_store_work_solution(struct work* work, uint32_t* hash, void* sol_data); int equi_verify_sol(void * const hdr, void * const sol); diff --git a/util.cpp b/util.cpp index 954f6b0..99187fd 100644 --- a/util.cpp +++ b/util.cpp @@ -1782,6 +1782,9 @@ static bool stratum_show_message(struct stratum_ctx *sctx, json_t *id, json_t *p json_t *val; bool ret; + if (sctx->is_equihash) + return equi_stratum_show_message(sctx, id, params); + val = json_array_get(params, 0); if (val) applog(LOG_NOTICE, "MESSAGE FROM SERVER: %s", json_string_value(val));