Skip to content

Commit a9d4945

Browse files
plugin-bcli:Added timer
Changelog-None Signed-off-by: Nishant Bansal <[email protected]>
1 parent e8586ea commit a9d4945

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

plugins/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ PLUGIN_COMMON_OBJS := \
192192
common/splice_script.o \
193193
common/setup.o \
194194
common/status_levels.o \
195+
common/timeout.o \
195196
common/utils.o \
196197
common/version.o \
197198
common/wireaddr.o \

plugins/bcli.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <common/json_param.h>
1111
#include <common/json_stream.h>
1212
#include <common/memleak.h>
13+
#include <common/timeout.h>
1314
#include <errno.h>
1415
#include <plugins/libplugin.h>
1516

@@ -1034,6 +1035,11 @@ static void parse_getnetworkinfo_result(struct plugin *p, const char *buf)
10341035
tal_free(result);
10351036
}
10361037

1038+
static void log_warm_up(struct plugin *p)
1039+
{
1040+
plugin_log(p, LOG_UNUSUAL, "Waiting for bitcoind to warm up...");
1041+
}
1042+
10371043
static void wait_and_check_bitcoind(struct plugin *p)
10381044
{
10391045
int in, from, status, ret;
@@ -1042,8 +1048,6 @@ static void wait_and_check_bitcoind(struct plugin *p)
10421048
gather_args(bitcoind, "-rpcwait", "getnetworkinfo", NULL);
10431049
char *output = NULL;
10441050

1045-
// plugin_log(p, LOG_UNUSUAL, "Waiting for bitcoind to warm up...");
1046-
10471051
child = pipecmdarr(&in, &from, &from, cast_const2(char **, cmd));
10481052

10491053
if (bitcoind->rpcpass)
@@ -1084,6 +1088,10 @@ static void wait_and_check_bitcoind(struct plugin *p)
10841088
cmd[0], WEXITSTATUS(status), output));
10851089
}
10861090

1091+
struct timers *timer = tal(cmd, struct timers);
1092+
timers_init(timer, time_mono());
1093+
new_reltimer(timer, timer, time_from_sec(30), log_warm_up, p);
1094+
10871095
parse_getnetworkinfo_result(p, output);
10881096

10891097
tal_free(cmd);

0 commit comments

Comments
 (0)