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

14
src/stratifier.c

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

Loading…
Cancel
Save