subd: Add a helper to get the current owning subd for a given peer

This is currently in opening_control since that's the only part that has
access to the uncommitted_channel internals. Otherwise it's independent from
the specific daemon.
This commit is contained in:
Christian Decker
2019-12-03 15:48:18 +01:00
parent a8fa55d275
commit 8d29338fe3
2 changed files with 16 additions and 1 deletions

View File

@@ -29,7 +29,6 @@
#include <lightningd/notification.h>
#include <lightningd/opening_control.h>
#include <lightningd/options.h>
#include <lightningd/peer_control.h>
#include <lightningd/plugin_hook.h>
#include <lightningd/subd.h>
#include <openingd/gen_opening_wire.h>
@@ -1338,3 +1337,16 @@ void opening_dev_memleak(struct command *cmd)
opening_memleak_req_next(cmd, NULL);
}
#endif /* DEVELOPER */
struct subd *peer_get_owning_subd(struct peer *peer)
{
struct channel *channel;
channel = peer_active_channel(peer);
if (channel != NULL) {
return channel->owner;
} else if (peer->uncommitted_channel != NULL) {
return peer->uncommitted_channel->openingd;
}
return NULL;
}

View File

@@ -2,6 +2,7 @@
#define LIGHTNING_LIGHTNINGD_OPENING_CONTROL_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <lightningd/peer_control.h>
struct channel_id;
struct crypto_state;
@@ -26,4 +27,6 @@ struct command;
void opening_dev_memleak(struct command *cmd);
#endif
struct subd *peer_get_owning_subd(struct peer *peer);
#endif /* LIGHTNING_LIGHTNINGD_OPENING_CONTROL_H */