mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 23:54:22 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user