mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
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>
This commit is contained in:
parent
0204c44243
commit
f0a12c5c23
@ -116,6 +116,12 @@ static char *bcli_args(struct bitcoin_cli *bcli)
|
|||||||
return ret;
|
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. */
|
/* We allow 60 seconds of spurious errors, eg. reorg. */
|
||||||
static void bcli_failure(struct bitcoind *bitcoind,
|
static void bcli_failure(struct bitcoind *bitcoind,
|
||||||
struct bitcoin_cli *bcli,
|
struct bitcoin_cli *bcli,
|
||||||
@ -139,6 +145,10 @@ static void bcli_failure(struct bitcoind *bitcoind,
|
|||||||
"%s exited with status %u", bcli_args(bcli), exitstatus);
|
"%s exited with status %u", bcli_args(bcli), exitstatus);
|
||||||
|
|
||||||
bitcoind->error_count++;
|
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)
|
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)
|
if (!ok)
|
||||||
bcli_failure(bitcoind, bcli, WEXITSTATUS(status));
|
bcli_failure(bitcoind, bcli, WEXITSTATUS(status));
|
||||||
|
else
|
||||||
|
tal_free(bcli);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tal_free(bcli);
|
|
||||||
|
|
||||||
next_bcli(bitcoind);
|
next_bcli(bitcoind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user