Browse Source

lightningd/bitcoind: always die if the Bitcoin backend died

This in addition removes the init fixed timeout hack.

Changelog-fixed: We now *always* die if our Bitcoin backend failed unexpectedly.
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
nifty/pset-pre
Antoine Poinsot 5 years ago
committed by neil saitug
parent
commit
678591d851
  1. 20
      lightningd/bitcoind.c

20
lightningd/bitcoind.c

@ -40,22 +40,22 @@ static const char *methods[] = {"getchaininfo", "getrawblockbyheight",
"sendrawtransaction", "getutxout", "sendrawtransaction", "getutxout",
"estimatefees"}; "estimatefees"};
static void bitcoin_destructor(struct plugin *p)
{
if (p->plugins->ld->state == LD_STATE_SHUTDOWN)
return;
fatal("The Bitcoin backend died.");
}
static void plugin_config_cb(const char *buffer, static void plugin_config_cb(const char *buffer,
const jsmntok_t *toks, const jsmntok_t *toks,
const jsmntok_t *idtok, const jsmntok_t *idtok,
struct plugin *plugin) struct plugin *plugin)
{ {
tal_free(plugin->timeout_timer);
plugin->plugin_state = CONFIGURED; plugin->plugin_state = CONFIGURED;
io_break(plugin); io_break(plugin);
} }
static void plugin_config_timeout(void *unused UNUSED)
{
fatal("Timed out while waiting for (one of) the Bitcoin backend "
"plugin(s) to complete the handshake.");
}
static void config_plugin(struct plugin *plugin) static void config_plugin(struct plugin *plugin)
{ {
struct jsonrpc_request *req; struct jsonrpc_request *req;
@ -66,11 +66,7 @@ static void config_plugin(struct plugin *plugin)
jsonrpc_request_end(req); jsonrpc_request_end(req);
plugin_request_send(plugin, req); plugin_request_send(plugin, req);
/* Don't hang forever if the plugin encountered a problem at init. */ tal_add_destructor(plugin, bitcoin_destructor);
plugin->timeout_timer
= new_reltimer(plugin->plugins->ld->timers, NULL,
time_from_sec(BITCOIN_INIT_TIMEOUT),
plugin_config_timeout, NULL);
io_loop_with_timers(plugin->plugins->ld); io_loop_with_timers(plugin->plugins->ld);
} }

Loading…
Cancel
Save