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.
This commit is contained in:
darosior 2020-01-07 16:09:59 +01:00 committed by Rusty Russell
parent ae249a2294
commit c4ff960b74
2 changed files with 7 additions and 0 deletions

View File

@ -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;

View File

@ -5,6 +5,7 @@
#include <bitcoin/tx.h>
#include <ccan/list/list.h>
#include <ccan/short_types/short_types.h>
#include <ccan/strmap/strmap.h>
#include <ccan/tal/tal.h>
#include <ccan/time/time.h>
#include <ccan/typesafe_cb/typesafe_cb.h>
@ -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 */