Browse Source

bitcoind: retry after one second if a call fails.

There are two recurring calls: the estimatefee call and the
getblockcount call.  Currently we simply discard them on error, the
timer isn't rearmed.

This should fix a number of cases where bitcoind has an intermittant
failure and lightningd simply stops collecting blocks.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
f0a12c5c23
  1. 14
      lightningd/bitcoind.c

14
lightningd/bitcoind.c

@ -116,6 +116,12 @@ static char *bcli_args(struct bitcoin_cli *bcli)
return ret;
}
static void retry_bcli(struct bitcoin_cli *bcli)
{
list_add_tail(&bcli->bitcoind->pending, &bcli->list);
next_bcli(bcli->bitcoind);
}
/* We allow 60 seconds of spurious errors, eg. reorg. */
static void bcli_failure(struct bitcoind *bitcoind,
struct bitcoin_cli *bcli,
@ -139,6 +145,10 @@ static void bcli_failure(struct bitcoind *bitcoind,
"%s exited with status %u", bcli_args(bcli), exitstatus);
bitcoind->error_count++;
/* Retry in 1 second */
new_reltimer(&bitcoind->ld->timers, bcli, time_from_sec(1),
retry_bcli, bcli);
}
static void bcli_finished(struct io_conn *conn UNUSED, struct bitcoin_cli *bcli)
@ -182,10 +192,10 @@ static void bcli_finished(struct io_conn *conn UNUSED, struct bitcoin_cli *bcli)
if (!ok)
bcli_failure(bitcoind, bcli, WEXITSTATUS(status));
else
tal_free(bcli);
done:
tal_free(bcli);
next_bcli(bitcoind);
}

Loading…
Cancel
Save