mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
plugin notifications: minor cleanups.
1. We don't need to check for NULL before tal_count(NULL). 2. Use of json_for_each_arr iterator is probably better. 3. Weird indent fixed. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ce1e5bd388
commit
214fdcc9d7
@ -109,9 +109,6 @@ void plugins_free(struct plugins *plugins)
|
|||||||
static void plugin_check_subscriptions(struct plugins *plugins,
|
static void plugin_check_subscriptions(struct plugins *plugins,
|
||||||
struct plugin *plugin)
|
struct plugin *plugin)
|
||||||
{
|
{
|
||||||
if (plugin->subscriptions == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < tal_count(plugin->subscriptions); i++) {
|
for (size_t i = 0; i < tal_count(plugin->subscriptions); i++) {
|
||||||
const char *topic = plugin->subscriptions[i];
|
const char *topic = plugin->subscriptions[i];
|
||||||
if (!notifications_have_topic(plugins, topic))
|
if (!notifications_have_topic(plugins, topic))
|
||||||
@ -1305,6 +1302,7 @@ static const char *plugin_notifications_add(const char *buffer,
|
|||||||
struct plugin *plugin)
|
struct plugin *plugin)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
size_t i;
|
||||||
const jsmntok_t *method, *obj;
|
const jsmntok_t *method, *obj;
|
||||||
const jsmntok_t *notifications =
|
const jsmntok_t *notifications =
|
||||||
json_get_member(buffer, result, "notifications");
|
json_get_member(buffer, result, "notifications");
|
||||||
@ -1316,8 +1314,7 @@ static const char *plugin_notifications_add(const char *buffer,
|
|||||||
return tal_fmt(plugin,
|
return tal_fmt(plugin,
|
||||||
"\"result.notifications\" is not an array");
|
"\"result.notifications\" is not an array");
|
||||||
|
|
||||||
for (size_t i = 0; i < notifications->size; i++) {
|
json_for_each_arr(i, obj, notifications) {
|
||||||
obj = json_get_arr(notifications, i);
|
|
||||||
if (obj->type != JSMN_OBJECT)
|
if (obj->type != JSMN_OBJECT)
|
||||||
return tal_fmt(
|
return tal_fmt(
|
||||||
plugin,
|
plugin,
|
||||||
|
@ -1834,9 +1834,11 @@ static void payment_json_add_attempts(struct json_stream *s,
|
|||||||
json_array_end(s);
|
json_array_end(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void payment_notify_failure(struct payment *p, const char *error_message) {
|
static void payment_notify_failure(struct payment *p, const char *error_message)
|
||||||
|
{
|
||||||
struct payment *root = payment_root(p);
|
struct payment *root = payment_root(p);
|
||||||
struct json_stream *n;
|
struct json_stream *n;
|
||||||
|
|
||||||
n = plugin_notification_start(p->plugin, "pay_failure");
|
n = plugin_notification_start(p->plugin, "pay_failure");
|
||||||
json_add_sha256(n, "payment_hash", p->payment_hash);
|
json_add_sha256(n, "payment_hash", p->payment_hash);
|
||||||
if (root->invstring != NULL)
|
if (root->invstring != NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user