Skip to content

Commit

Permalink
equihash: use client.show_message to get block height
Browse files Browse the repository at this point in the history
current stratum is imcomplete and doesnt provide the coinbase data
  • Loading branch information
tpruvot committed Jul 13, 2017
1 parent 7ce3f2c commit 5aa50a4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ccminer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
<CodeGeneration>compute_52,sm_52;compute_50,sm_50;compute_30,sm_30</CodeGeneration>
<AdditionalOptions> -Xptxas -dlcm=ca -Xptxas -dscm=cs %(AdditionalOptions)</AdditionalOptions>
<MaxRegCount>0</MaxRegCount>
<CodeGeneration Condition="'$(Configuration)|$(Platform)'=='Release|x64'">compute_61,sm_61;compute_52,sm_52;compute_50,sm_50;compute_30,sm_30</CodeGeneration>
</CudaCompile>
<CudaCompile Include="neoscrypt\cuda_neoscrypt.cu">
<MaxRegCount>160</MaxRegCount>
Expand Down Expand Up @@ -599,4 +600,4 @@
<Target Name="AfterClean">
<Delete Files="@(FilesToCopy->'$(OutDir)%(Filename)%(Extension)')" TreatErrorsAsWarnings="true" />
</Target>
</Project>
</Project>
32 changes: 32 additions & 0 deletions equi/equi-stratum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,38 @@ bool equi_stratum_notify(struct stratum_ctx *sctx, json_t *params)
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;
Expand Down
1 change: 1 addition & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 5aa50a4

Please sign in to comment.