Browse Source

Ping miners regularly in proxy mode to ensure they don't disconnect when diff is too high for them and they receive no update

master
Con Kolivas 10 years ago
parent
commit
e441e65c53
  1. 23
      src/stratifier.c

23
src/stratifier.c

@ -1144,6 +1144,21 @@ static void block_solve(ckpool_t *ckp)
}
/* Some upstream pools (like p2pool) don't update stratum often enough and
* miners disconnect if they don't receive regular communication so send them
* a ping at regular intervals */
static void broadcast_ping(void)
{
json_t *json_msg;
JSON_CPACK(json_msg, "{s:[],s:o,s:s}",
"params",
"id", json_null(),
"method", "mining.ping");
stratum_broadcast(json_msg);
}
static int stratum_loop(ckpool_t *ckp, proc_instance_t *pi)
{
int sockd, ret = 0, selret = 0;
@ -1153,7 +1168,6 @@ static int stratum_loop(ckpool_t *ckp, proc_instance_t *pi)
retry:
do {
if (!ckp->proxy) {
double tdiff;
tv_t end_tv;
@ -1161,11 +1175,16 @@ retry:
tdiff = tvdiff(&end_tv, &start_tv);
if (tdiff > ckp->update_interval) {
copy_tv(&start_tv, &end_tv);
if (!ckp->proxy) {
LOGDEBUG("%ds elapsed in strat_loop, updating gbt base",
ckp->update_interval);
update_base(ckp, GEN_NORMAL);
continue;
} else {
LOGDEBUG("%ds elapsed in strat_loop, pinging miners",
ckp->update_interval);
broadcast_ping();
}
continue;
}
selret = wait_read_select(us->sockd, 5);
if (!selret && !ping_main(ckp)) {

Loading…
Cancel
Save