|
|
@ -800,33 +800,21 @@ static void send_generator(ckpool_t *ckp, const char *msg, const int prio) |
|
|
|
sdata->gen_priority = 0; |
|
|
|
sdata->gen_priority = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct update_req { |
|
|
|
|
|
|
|
pthread_t *pth; |
|
|
|
|
|
|
|
ckpool_t *ckp; |
|
|
|
|
|
|
|
int prio; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void broadcast_ping(sdata_t *sdata); |
|
|
|
static void broadcast_ping(sdata_t *sdata); |
|
|
|
|
|
|
|
|
|
|
|
/* This function assumes it will only receive a valid json gbt base template
|
|
|
|
/* This function assumes it will only receive a valid json gbt base template
|
|
|
|
* since checking should have been done earlier, and creates the base template |
|
|
|
* since checking should have been done earlier, and creates the base template |
|
|
|
* for generating work templates. */ |
|
|
|
* for generating work templates. */ |
|
|
|
static void *do_update(void *arg) |
|
|
|
static void do_update(ckpool_t *ckp, int *prio) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct update_req *ur = (struct update_req *)arg; |
|
|
|
|
|
|
|
ckpool_t *ckp = ur->ckp; |
|
|
|
|
|
|
|
sdata_t *sdata = ckp->data; |
|
|
|
sdata_t *sdata = ckp->data; |
|
|
|
bool new_block = false; |
|
|
|
bool new_block = false; |
|
|
|
int prio = ur->prio; |
|
|
|
|
|
|
|
bool ret = false; |
|
|
|
bool ret = false; |
|
|
|
workbase_t *wb; |
|
|
|
workbase_t *wb; |
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
char *buf; |
|
|
|
char *buf; |
|
|
|
|
|
|
|
|
|
|
|
pthread_detach(pthread_self()); |
|
|
|
buf = send_recv_generator(ckp, "getbase", *prio); |
|
|
|
rename_proc("updater"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf = send_recv_generator(ckp, "getbase", prio); |
|
|
|
|
|
|
|
if (unlikely(!buf)) { |
|
|
|
if (unlikely(!buf)) { |
|
|
|
LOGNOTICE("Get base in update_base delayed due to higher priority request"); |
|
|
|
LOGNOTICE("Get base in update_base delayed due to higher priority request"); |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
@ -886,21 +874,17 @@ out: |
|
|
|
LOGINFO("Broadcast ping due to failed stratum base update"); |
|
|
|
LOGINFO("Broadcast ping due to failed stratum base update"); |
|
|
|
broadcast_ping(sdata); |
|
|
|
broadcast_ping(sdata); |
|
|
|
} |
|
|
|
} |
|
|
|
dealloc(buf); |
|
|
|
free(buf); |
|
|
|
free(ur->pth); |
|
|
|
free(prio); |
|
|
|
free(ur); |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void update_base(ckpool_t *ckp, const int prio) |
|
|
|
static void update_base(ckpool_t *ckp, const int prio) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct update_req *ur = ckalloc(sizeof(struct update_req)); |
|
|
|
int *pprio = ckalloc(sizeof(int)); |
|
|
|
pthread_t *pth = ckalloc(sizeof(pthread_t)); |
|
|
|
sdata_t *sdata = ckp->data; |
|
|
|
|
|
|
|
|
|
|
|
ur->pth = pth; |
|
|
|
*pprio = prio; |
|
|
|
ur->ckp = ckp; |
|
|
|
ckwq_add(sdata->ckwqs, &do_update, pprio); |
|
|
|
ur->prio = prio; |
|
|
|
|
|
|
|
create_pthread(pth, do_update, ur); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void __kill_instance(stratum_instance_t *client) |
|
|
|
static void __kill_instance(stratum_instance_t *client) |
|
|
|