diff --git a/connectd/multiplex.c b/connectd/multiplex.c index cdcb17a0c..2d0ee88b2 100644 --- a/connectd/multiplex.c +++ b/connectd/multiplex.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +31,7 @@ #include #include #include +#include void queue_peer_msg(struct peer *peer, const u8 *msg TAKES) { @@ -334,7 +337,7 @@ again: return NULL; } -/* We only handle gossip_timestamp_filter for now */ +/* We handle gossip_timestamp_filter, and divert other gossip msgs to gossipd */ static bool handle_message_locally(struct peer *peer, const u8 *msg) { struct bitcoin_blkid chain_hash; @@ -347,6 +350,18 @@ static bool handle_message_locally(struct peer *peer, const u8 *msg) if (!fromwire_gossip_timestamp_filter(msg, &chain_hash, &first_timestamp, ×tamp_range)) { + /* Do we want to divert to gossipd? */ + if (is_msg_for_gossipd(msg)) { + u8 *gmsg = towire_gossipd_recv_gossip(NULL, + &peer->id, msg); + + /* gossipd doesn't log IO, so we log it here. */ + status_peer_io(LOG_IO_IN, &peer->id, msg); + + daemon_conn_send(peer->daemon->gossipd, take(gmsg)); + return true; + } + return false; } diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 3e90a2dae..88ab7bab3 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -682,27 +682,6 @@ static struct io_plan *peer_msg_in(struct io_conn *conn, /* These are messages relayed from peer */ switch ((enum peer_wire)fromwire_peektype(msg)) { - case WIRE_CHANNEL_ANNOUNCEMENT: - err = handle_channel_announcement_msg(peer->daemon, peer, msg); - goto handled_relay; - case WIRE_CHANNEL_UPDATE: - err = handle_channel_update_msg(peer, msg); - goto handled_relay; - case WIRE_NODE_ANNOUNCEMENT: - err = handle_node_announce(peer, msg); - goto handled_relay; - case WIRE_QUERY_CHANNEL_RANGE: - err = handle_query_channel_range(peer, msg); - goto handled_relay; - case WIRE_REPLY_CHANNEL_RANGE: - err = handle_reply_channel_range(peer, msg); - goto handled_relay; - case WIRE_QUERY_SHORT_CHANNEL_IDS: - err = handle_query_short_channel_ids(peer, msg); - goto handled_relay; - case WIRE_REPLY_SHORT_CHANNEL_IDS_END: - err = handle_reply_short_channel_ids_end(peer, msg); - goto handled_relay; case WIRE_OBS2_ONION_MESSAGE: err = handle_obs2_onion_message(peer, msg); goto handled_relay; @@ -710,7 +689,14 @@ static struct io_plan *peer_msg_in(struct io_conn *conn, err = handle_onion_message(peer, msg); goto handled_relay; - /* These are non-gossip messages (!is_msg_for_gossipd()) */ + /* These are not sent by peer (connectd sends us gossip msgs) */ + case WIRE_CHANNEL_ANNOUNCEMENT: + case WIRE_CHANNEL_UPDATE: + case WIRE_NODE_ANNOUNCEMENT: + case WIRE_QUERY_CHANNEL_RANGE: + case WIRE_REPLY_CHANNEL_RANGE: + case WIRE_QUERY_SHORT_CHANNEL_IDS: + case WIRE_REPLY_SHORT_CHANNEL_IDS_END: case WIRE_WARNING: case WIRE_INIT: case WIRE_ERROR: