Browse Source

Cache and use value of current_workbase in __stratum_notify

master
Con Kolivas 10 years ago
parent
commit
102ed8748b
  1. 22
      src/stratifier.c

22
src/stratifier.c

@ -3010,20 +3010,20 @@ out:
} }
/* Must enter with workbase_lock held */ /* Must enter with workbase_lock held */
static json_t *__stratum_notify(sdata_t *sdata, bool clean) static json_t *__stratum_notify(const workbase_t *wb, const bool clean)
{ {
json_t *val; json_t *val;
JSON_CPACK(val, "{s:[ssssosssb],s:o,s:s}", JSON_CPACK(val, "{s:[ssssosssb],s:o,s:s}",
"params", "params",
sdata->current_workbase->idstring, wb->idstring,
sdata->current_workbase->prevhash, wb->prevhash,
sdata->current_workbase->coinb1, wb->coinb1,
sdata->current_workbase->coinb2, wb->coinb2,
json_deep_copy(sdata->current_workbase->merkle_array), json_deep_copy(wb->merkle_array),
sdata->current_workbase->bbversion, wb->bbversion,
sdata->current_workbase->nbit, wb->nbit,
sdata->current_workbase->ntime, wb->ntime,
clean, clean,
"id", json_null(), "id", json_null(),
"method", "mining.notify"); "method", "mining.notify");
@ -3035,7 +3035,7 @@ static void stratum_broadcast_update(sdata_t *sdata, bool clean)
json_t *json_msg; json_t *json_msg;
ck_rlock(&sdata->workbase_lock); ck_rlock(&sdata->workbase_lock);
json_msg = __stratum_notify(sdata, clean); json_msg = __stratum_notify(sdata->current_workbase, clean);
ck_runlock(&sdata->workbase_lock); ck_runlock(&sdata->workbase_lock);
stratum_broadcast(sdata, json_msg); stratum_broadcast(sdata, json_msg);
@ -3047,7 +3047,7 @@ static void stratum_send_update(sdata_t *sdata, int64_t client_id, bool clean)
json_t *json_msg; json_t *json_msg;
ck_rlock(&sdata->workbase_lock); ck_rlock(&sdata->workbase_lock);
json_msg = __stratum_notify(sdata, clean); json_msg = __stratum_notify(sdata->current_workbase, clean);
ck_runlock(&sdata->workbase_lock); ck_runlock(&sdata->workbase_lock);
stratum_add_send(sdata, json_msg, client_id); stratum_add_send(sdata, json_msg, client_id);

Loading…
Cancel
Save