Browse Source

Cope with failure to get a single block template more gracefully

master
Con Kolivas 11 years ago
parent
commit
91854f81ec
  1. 6
      src/generator.c
  2. 14
      src/stratifier.c

6
src/generator.c

@ -59,8 +59,7 @@ retry:
free(s); free(s);
clear_gbtbase(&gbt); clear_gbtbase(&gbt);
} }
} } else if (!strncasecmp(buf, "getbest", 7)) {
if (!strncasecmp(buf, "getbest", 7)) {
if (!get_bestblockhash(cs, hash)) { if (!get_bestblockhash(cs, hash)) {
LOGWARNING("No best block hash support from %s:%s", LOGWARNING("No best block hash support from %s:%s",
cs->url, cs->port); cs->url, cs->port);
@ -68,8 +67,7 @@ retry:
} else { } else {
send_unix_msg(sockd, hash); send_unix_msg(sockd, hash);
} }
} } else if (!strncasecmp(buf, "getlast", 7)) {
if (!strncasecmp(buf, "getlast", 7)) {
int height = get_blockcount(cs); int height = get_blockcount(cs);
if (height == -1) if (height == -1)

14
src/stratifier.c

@ -279,12 +279,17 @@ static void update_base(ckpool_t *ckp)
json_t *val; json_t *val;
char *buf; char *buf;
wb = ckzalloc(sizeof(workbase_t));
buf = send_recv_proc(&ckp->generator, "getbase"); buf = send_recv_proc(&ckp->generator, "getbase");
if (unlikely(!buf)) { if (unlikely(!buf)) {
LOGWARNING("Failed to get base from generator in update_base"); LOGWARNING("Failed to get base from generator in update_base");
return; return;
} }
if (unlikely(!strncasecmp(buf, "failed", 6))) {
LOGWARNING("Generator returned failure in update_base");
return;
}
wb = ckzalloc(sizeof(workbase_t));
val = json_loads(buf, 0, NULL); val = json_loads(buf, 0, NULL);
dealloc(buf); dealloc(buf);
@ -679,8 +684,11 @@ static void add_submit(stratum_instance_t *client, int diff)
return; return;
optimal = dsps * 3; optimal = dsps * 3;
if (optimal <= 1 && client->diff == 1) if (optimal <= 1) {
return; if (client->diff == 1)
return;
optimal = 1;
}
ck_rlock(&workbase_lock); ck_rlock(&workbase_lock);
next_blockid = workbase_id + 1; next_blockid = workbase_id + 1;

Loading…
Cancel
Save