diff --git a/lightningd/channel/channel.c b/lightningd/channel/channel.c index a5824328d..fbc17a9bb 100644 --- a/lightningd/channel/channel.c +++ b/lightningd/channel/channel.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +55,7 @@ struct peer { const u8 **peer_out; int gossip_client_fd; + struct daemon_conn gossip_client; }; static void msg_enqueue(const u8 ***q, const u8 *add) @@ -81,6 +84,20 @@ static void queue_pkt(struct peer *peer, const u8 *msg) io_wake(peer); } +static struct io_plan *gossip_client_recv(struct io_conn *conn, + struct daemon_conn *dc) +{ + u8 *msg = dc->msg_in; + struct peer *peer = container_of(dc, struct peer, gossip_client); + u16 type = fromwire_peektype(msg); + + if (type == WIRE_CHANNEL_ANNOUNCEMENT || type == WIRE_CHANNEL_UPDATE || + type == WIRE_NODE_ANNOUNCEMENT) + queue_pkt(peer, msg); + + return daemon_conn_read_next(conn, dc); +} + static struct io_plan *peer_out(struct io_conn *conn, struct peer *peer) { const u8 *out = msg_dequeue(&peer->peer_out); @@ -202,6 +219,10 @@ int main(int argc, char *argv[]) tal_hex(msg, msg)); tal_free(msg); peer->gossip_client_fd = fdpass_recv(REQ_FD); + + daemon_conn_init(peer, &peer->gossip_client, peer->gossip_client_fd, + gossip_client_recv); + if (peer->gossip_client_fd == -1) status_failed( WIRE_CHANNEL_BAD_COMMAND,