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

@@ -315,7 +315,7 @@ u8 *cryptomsg_encrypt_msg(const tal_t *ctx,
tal_hexstr(trc, msg, mlen),
tal_hexstr(trc, npub, sizeof(npub)),
tal_hexstr(trc, &cs->sk, sizeof(cs->sk)),
tal_hexstr(trc, out + 18, clen));
tal_hexstr(trc, out + CRYPTOMSG_HDR_SIZE, clen));
#endif
maybe_rotate_key(&cs->sn, &cs->sk, &cs->s_ck);