mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
plugin: Add function to collect featurebits that plugins registered
This commit is contained in:
parent
9b976da3bc
commit
532bf1730f
@ -3,6 +3,7 @@
|
||||
#include <ccan/opt/opt.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <ccan/utf8/utf8.h>
|
||||
#include <common/features.h>
|
||||
#include <common/utils.h>
|
||||
#include <common/version.h>
|
||||
#include <lightningd/json.h>
|
||||
@ -46,6 +47,18 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
||||
return p;
|
||||
}
|
||||
|
||||
u8 *plugins_collect_featurebits(const tal_t *ctx, const struct plugins *plugins,
|
||||
enum plugin_features_type type)
|
||||
{
|
||||
struct plugin *p;
|
||||
u8 *res = tal_arr(ctx, u8, 0);
|
||||
list_for_each(&plugins->plugins, p, list) {
|
||||
if (p->featurebits[type])
|
||||
res = featurebits_or(ctx, take(res), p->featurebits[type]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void destroy_plugin(struct plugin *p)
|
||||
{
|
||||
plugin_hook_unregister_all(p);
|
||||
|
@ -266,4 +266,8 @@ struct log *plugin_get_log(struct plugin *plugin);
|
||||
struct plugin_destroyed *plugin_detect_destruction(const struct plugin *plugin);
|
||||
bool was_plugin_destroyed(struct plugin_destroyed *destroyed);
|
||||
|
||||
/* Gather all the features of the given type that plugins registered. */
|
||||
u8 *plugins_collect_featurebits(const tal_t *ctx, const struct plugins *plugins,
|
||||
enum plugin_features_type type);
|
||||
|
||||
#endif /* LIGHTNING_LIGHTNINGD_PLUGIN_H */
|
||||
|
Loading…
Reference in New Issue
Block a user