plugin: Add a list of notification topics registered by plugin

We will eventually start emitting and dispatching custom notifications
from plugins just like we dispatch internal notifications. In order to
get reasonable error messages we need to make sure that the topics
plugins are asking for were correctly registered. When doing this we
don't really care about whether the plugin that registered the
notification is still alive or not (it might have died, but
subscribers should stay up and running), so we keep a list of all
topics attached to the `struct plugins` which gathers global plugin
information.
This commit is contained in:
Christian Decker
2021-04-27 15:15:09 +02:00
committed by Rusty Russell
parent 29155c2fe8
commit 083b41f090
7 changed files with 80 additions and 9 deletions

View File

@@ -18,12 +18,19 @@ static struct notification *find_notification_by_topic(const char* topic)
return NULL;
}
bool notifications_have_topic(const char *topic)
bool notifications_have_topic(const struct plugins *plugins, const char *topic)
{
struct notification *noti = find_notification_by_topic(topic);
if (noti)
return true;
/* Some plugin at some point announced it'd be emitting
* notifications to this topic. We don't care if it died, just
* that it was a valid topic at some point in time. */
for (size_t i=0; i<tal_count(plugins->notification_topics); i++)
if (streq(plugins->notification_topics[i], topic))
return true;
return false;
}