connectd/peer_exchange_initmsg: handle peer comms ourselves.

connectd is the only user of the cryptomsg async APIs; better to
open-code it here.  We need to expose a little from cryptomsg(),
but we remove the 'struct peer' entirely from connectd.

One trick is that we still need to defer telling lightningd when a
peer reconnects (until it tells us the old one is disconnected).  So
now we generate the message for lightningd and send it once we're woken.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-09-28 06:34:19 +09:30
parent cfd54d67cb
commit a1bdaa8f99
7 changed files with 290 additions and 146 deletions

View File

@@ -0,0 +1,18 @@
#ifndef LIGHTNING_CONNECTD_PEER_EXCHANGE_INITMSG_H
#define LIGHTNING_CONNECTD_PEER_EXCHANGE_INITMSG_H
#include "config.h"
struct crypto_state;
struct daemon;
struct io_conn;
struct pubkey;
struct wireaddr_internal;
/* If successful, calls peer_connected() */
struct io_plan *peer_exchange_initmsg(struct io_conn *conn,
struct daemon *daemon,
const struct crypto_state *cs,
const struct pubkey *id,
const struct wireaddr_internal *addr);
#endif /* LIGHTNING_CONNECTD_PEER_EXCHANGE_INITMSG_H */