mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 17:14:22 +01:00
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>
38 lines
1.2 KiB
C
38 lines
1.2 KiB
C
#ifndef LIGHTNING_CONNECTD_MULTIPLEX_H
|
|
#define LIGHTNING_CONNECTD_MULTIPLEX_H
|
|
#include "config.h"
|
|
#include <ccan/short_types/short_types.h>
|
|
#include <common/crypto_state.h>
|
|
#include <common/msg_queue.h>
|
|
#include <common/node_id.h>
|
|
|
|
struct peer;
|
|
struct io_conn;
|
|
struct feature_set;
|
|
|
|
/* Take over peer_conn as peer->to_peer */
|
|
struct io_plan *multiplex_peer_setup(struct io_conn *peer_conn,
|
|
struct peer *peer);
|
|
|
|
/* Send this message to peer and disconnect. */
|
|
void multiplex_final_msg(struct peer *peer,
|
|
const u8 *final_msg TAKES);
|
|
|
|
/* Inject a message into the output stream. Unlike a raw msg_enqueue,
|
|
* this does io logging. */
|
|
void inject_peer_msg(struct peer *peer, const u8 *msg TAKES);
|
|
|
|
void setup_peer_gossip_store(struct peer *peer,
|
|
const struct feature_set *our_features,
|
|
const u8 *their_features);
|
|
|
|
/* When lightningd says to send a ping */
|
|
void send_manual_ping(struct daemon *daemon, const u8 *msg);
|
|
|
|
/* When lightningd says to send a custom message (from a plugin) */
|
|
void send_custommsg(struct daemon *daemon, const u8 *msg);
|
|
|
|
/* Lightningd wants to talk to you. */
|
|
void peer_connect_subd(struct daemon *daemon, const u8 *msg, int fd);
|
|
#endif /* LIGHTNING_CONNECTD_MULTIPLEX_H */
|