From c4ff960b74a7da504e2aea5a86b8b75375d71827 Mon Sep 17 00:00:00 2001 From: darosior Date: Tue, 7 Jan 2020 16:09:59 +0100 Subject: [PATCH] bitcoind: allow commands to be registered by different plugins An strmap is convenient to get a plugin given a method. Populate it while checking commands. --- lightningd/bitcoind.c | 2 ++ lightningd/bitcoind.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lightningd/bitcoind.c b/lightningd/bitcoind.c index 5df163d64..713bd6ab8 100644 --- a/lightningd/bitcoind.c +++ b/lightningd/bitcoind.c @@ -1011,6 +1011,7 @@ static bool process_getblockchaininfo(struct bitcoin_cli *bcli) static void destroy_bitcoind(struct bitcoind *bitcoind) { + strmap_clear(&bitcoind->pluginsmap); /* Suppresses the callbacks from bcli_finished as we free conns. */ bitcoind->shutdown = true; } @@ -1146,6 +1147,7 @@ struct bitcoind *new_bitcoind(const tal_t *ctx, { struct bitcoind *bitcoind = tal(ctx, struct bitcoind); + strmap_init(&bitcoind->pluginsmap); bitcoind->cli = NULL; bitcoind->datadir = NULL; bitcoind->ld = ld; diff --git a/lightningd/bitcoind.h b/lightningd/bitcoind.h index 5b1e22966..f39af0b7c 100644 --- a/lightningd/bitcoind.h +++ b/lightningd/bitcoind.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,10 @@ struct bitcoind { char *rpcuser, *rpcpass, *rpcconnect, *rpcport; struct list_head pending_getfilteredblock; + + /* Map each method to a plugin, so we can have multiple plugins + * handling different functionalities. */ + STRMAP(struct plugin *) pluginsmap; }; /* A single outpoint in a filtered block */