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>
This commit is contained in:
Rusty Russell
2022-07-18 21:42:18 +09:30
committed by neil saitug
parent 430d6521a0
commit 41b379ed89
14 changed files with 380 additions and 288 deletions

View File

@@ -9,7 +9,7 @@ struct peer_fd;
bool peer_start_dualopend(struct peer *peer, struct peer_fd *peer_fd,
struct channel *channel);
void peer_restart_dualopend(struct peer *peer,
bool peer_restart_dualopend(struct peer *peer,
struct peer_fd *peer_fd,
struct channel *channel);