From 231069b2ba775af9829dc0511a2e6049605aca71 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 30 Dec 2015 09:21:23 +1100 Subject: [PATCH] Tidy send_node_workinfo --- src/stratifier.c | 49 ++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 257e9c71..9aa523d9 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -789,31 +789,10 @@ static void _ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val, const char static void stratum_add_send(sdata_t *sdata, json_t *val, const int64_t client_id, const int msg_type); -static void send_workinfo(ckpool_t *ckp, sdata_t *sdata, const workbase_t *wb) +static void send_node_workinfo(sdata_t *sdata, const workbase_t *wb) { stratum_instance_t *client; ckmsg_t *bulk_send = NULL; - char cdfield[64]; - json_t *val; - - sprintf(cdfield, "%lu,%lu", wb->gentime.tv_sec, wb->gentime.tv_nsec); - - JSON_CPACK(val, "{sI,ss,ss,ss,ss,ss,ss,ss,ss,sI,so,ss,ss,ss,ss}", - "workinfoid", wb->id, - "poolinstance", ckp->name, - "transactiontree", wb->txn_hashes, - "prevhash", wb->prevhash, - "coinbase1", wb->coinb1, - "coinbase2", wb->coinb2, - "version", wb->bbversion, - "ntime", wb->ntime, - "bits", wb->nbit, - "reward", wb->coinbasevalue, - "merklehash", json_deep_copy(wb->merkle_array), - "createdate", cdfield, - "createby", "code", - "createcode", __func__, - "createinet", ckp->serverurl[0]); ck_rlock(&sdata->instance_lock); if (sdata->node_instances) { @@ -871,7 +850,33 @@ static void send_workinfo(ckpool_t *ckp, sdata_t *sdata, const workbase_t *wb) pthread_cond_signal(ssends->cond); mutex_unlock(ssends->lock); } +} + +static void send_workinfo(ckpool_t *ckp, sdata_t *sdata, const workbase_t *wb) +{ + char cdfield[64]; + json_t *val; + + sprintf(cdfield, "%lu,%lu", wb->gentime.tv_sec, wb->gentime.tv_nsec); + + JSON_CPACK(val, "{sI,ss,ss,ss,ss,ss,ss,ss,ss,sI,so,ss,ss,ss,ss}", + "workinfoid", wb->id, + "poolinstance", ckp->name, + "transactiontree", wb->txn_hashes, + "prevhash", wb->prevhash, + "coinbase1", wb->coinb1, + "coinbase2", wb->coinb2, + "version", wb->bbversion, + "ntime", wb->ntime, + "bits", wb->nbit, + "reward", wb->coinbasevalue, + "merklehash", json_deep_copy(wb->merkle_array), + "createdate", cdfield, + "createby", "code", + "createcode", __func__, + "createinet", ckp->serverurl[0]); ckdbq_add(ckp, ID_WORKINFO, val); + send_node_workinfo(sdata, wb); } static void send_ageworkinfo(ckpool_t *ckp, const int64_t id)