Browse Source

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.
travis-debug
Christian Decker 5 years ago
parent
commit
8d29338fe3
  1. 14
      lightningd/opening_control.c
  2. 3
      lightningd/opening_control.h

14
lightningd/opening_control.c

@ -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;
}

3
lightningd/opening_control.h

@ -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 */

Loading…
Cancel
Save