Skip to content

Commit 9d5f208

Browse files
NicolasDorierKukks
authored andcommitted
Workaround for c-lightning to wait bitcoin core to start
1 parent 062afa3 commit 9d5f208

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

plugins/bcli.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ static void wait_and_check_bitcoind(struct plugin *p)
833833
pid_t child;
834834
const char **cmd = gather_args(bitcoind, "getnetworkinfo", NULL);
835835
bool printed = false;
836+
bool isWarmup = false;
836837
char *output = NULL;
837838

838839
for (;;) {
@@ -862,17 +863,20 @@ static void wait_and_check_bitcoind(struct plugin *p)
862863
/* bitcoin/src/rpc/protocol.h:
863864
* RPC_IN_WARMUP = -28, //!< Client still warming up
864865
*/
865-
if (WEXITSTATUS(status) != 28) {
866-
if (WEXITSTATUS(status) == 1)
867-
bitcoind_failure(p, "Could not connect to bitcoind using"
868-
" bitcoin-cli. Is bitcoind running?");
869-
bitcoind_failure(p, tal_fmt(bitcoind, "%s exited with code %i: %s",
870-
cmd[0], WEXITSTATUS(status), output));
871-
}
866+
isWarmup = WEXITSTATUS(status) == 28;
872867

873868
if (!printed) {
874-
plugin_log(p, LOG_UNUSUAL,
875-
"Waiting for bitcoind to warm up...");
869+
if (isWarmup)
870+
{
871+
plugin_log(p, LOG_UNUSUAL,
872+
"Waiting for bitcoind to warm up...");
873+
}
874+
else
875+
{
876+
plugin_log(p, LOG_UNUSUAL,
877+
tal_fmt(bitcoind, "%s exited with code %i: %s... retrying",
878+
cmd[0], WEXITSTATUS(status), output));
879+
}
876880
printed = true;
877881
}
878882
sleep(1);

0 commit comments

Comments
 (0)