core-lightning/lightningd/dual_open_control.h
Rusty Russell 41b379ed89 lightningd: hand fds to connectd, not receive them from connectd.
Before this patch:
1. connectd says it's connected (peer_connected)
2. we tell connectd we want to talk about each channel (peer_make_active)
3. connectd gives us an fd for each channel, and we connect it to a subd (peer_active)
4. OR, connectd says it sent something about a channel we didn't tell it about, with an fd (peer_active)

Now:
1. connectd says it's connected (peer_connected)
2. we start all appropriate subds and tell connectd to what channels/fds (peer_connect_subd).
3. if connectd says it sent something about a channel we didn't tell it about, we either tell
   it to hang up (peer_final_msg), or connect a new opening daemon (peer_connect_subd).

This is the minimal-size patch, which is why we create socket pairs in
so many places to use the existing functions.  Many cleanups are
possible, since the new flow is so simple.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-18 20:50:04 -05:00

31 lines
928 B
C

#ifndef LIGHTNING_LIGHTNINGD_DUAL_OPEN_CONTROL_H
#define LIGHTNING_LIGHTNINGD_DUAL_OPEN_CONTROL_H
#include "config.h"
#include <lightningd/subd.h>
struct peer_fd;
bool peer_start_dualopend(struct peer *peer, struct peer_fd *peer_fd,
struct channel *channel);
bool peer_restart_dualopend(struct peer *peer,
struct peer_fd *peer_fd,
struct channel *channel);
void dualopen_tell_depth(struct subd *dualopend,
struct channel *channel,
const struct bitcoin_txid *txid,
u32 depth);
/* Close connection to an unsaved channel */
void channel_unsaved_close_conn(struct channel *channel, const char *why);
void json_add_unsaved_channel(struct json_stream *response,
const struct channel *channel);
void channel_update_reserve(struct channel *channel,
struct channel_config *their_config,
struct amount_sat funding_total);
#endif /* LIGHTNING_LIGHTNINGD_DUAL_OPEN_CONTROL_H */