From d439d955e9af28d63e47a0e198e4d33f1e9c0f19 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 27 Jul 2018 11:34:28 +1000 Subject: [PATCH] Update vmask on existing proxy clients if it's changed late. --- src/stratifier.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index bceae152..68a83fab 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -3045,15 +3045,6 @@ out: json_decref(val); } -void stratum_set_proxy_vmask(ckpool_t *ckp, int id, int subid, uint32_t version_mask) -{ - proxy_t *proxy; - - proxy = subproxy_by_id(ckp->sdata, id, subid); - proxy->version_mask = version_mask; - LOGINFO("Stratum Proxy %d:%d had version mask set to %08x", id, subid, version_mask); -} - static void stratum_send_diff(sdata_t *sdata, const stratum_instance_t *client); static void update_diff(ckpool_t *ckp, const char *cmd) @@ -6516,6 +6507,29 @@ static void stratum_send_version_mask(sdata_t *sdata, stratum_instance_t *client stratum_add_send(sdata, json_msg, client->id, SM_VERSIONMASK); } +void stratum_set_proxy_vmask(ckpool_t *ckp, int id, int subid, uint32_t version_mask) +{ + stratum_instance_t *client, *tmp; + sdata_t *sdata = ckp->sdata; + proxy_t *proxy; + + proxy = subproxy_by_id(ckp->sdata, id, subid); + if (proxy->version_mask == version_mask) + return; + proxy->version_mask = version_mask; + LOGINFO("Stratum Proxy %d:%d had version mask set to %08x", id, subid, version_mask); + + ck_rlock(&sdata->instance_lock); + HASH_ITER(hh, sdata->stratum_instances, client, tmp) { + if (client->proxy != proxy) + continue; + if (!client->version_mask) + continue; + stratum_send_version_mask(client->sdata, client); + } + ck_runlock(&sdata->instance_lock); +} + /* Send diff first when sending the first stratum template after subscribing */ static void init_client(ckpool_t *ckp, stratum_instance_t *client, const int64_t client_id) {