lightningd/gossip: Move INIT message handling to handshake daemon.

We need to do this on every connection, whether reconnecting or not,
so it makes sense for the handshake daemon to handle it and return
the feature fields.

Longer term I'm considering having the handshake daemon handle the
listening and connecting, and simply hand the fds back once the peers
are ready.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-05-22 20:56:51 +09:30
parent 0c8b24cf97
commit 662dfef436
7 changed files with 120 additions and 110 deletions

View File

@@ -95,26 +95,6 @@ static void peer_nongossip(struct subd *gossip, const u8 *msg,
peer_accept_open(peer, &cs, inner);
}
static void peer_ready(struct subd *gossip, const u8 *msg)
{
u64 unique_id;
struct peer *peer;
if (!fromwire_gossipstatus_peer_ready(msg, NULL, &unique_id))
fatal("Gossip gave bad PEER_READY message %s",
tal_hex(msg, msg));
peer = peer_by_unique_id(gossip->ld, unique_id);
if (!peer)
fatal("Gossip gave bad peerid %"PRIu64, unique_id);
log_debug(gossip->log, "Peer %s (%"PRIu64") ready for channel open",
type_to_string(msg, struct pubkey, peer->id),
unique_id);
peer_set_condition(peer, GOSSIPING);
}
static int gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
{
enum gossip_wire_type t = fromwire_peektype(msg);
@@ -155,9 +135,6 @@ static int gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
return 2;
peer_nongossip(gossip, msg, fds[0], fds[1]);
break;
case WIRE_GOSSIPSTATUS_PEER_READY:
peer_ready(gossip, msg);
break;
}
return 0;
}