diff --git a/connectd/connectd.c b/connectd/connectd.c index 632c4ab0bbd2..dd6da6f05948 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -53,7 +53,6 @@ * thus may know how to reach certain peers. */ #define HSM_FD 3 #define GOSSIPCTL_FD 4 -#define GOSSIPCTL2_FD 5 /*~ In C convention, constants are UPPERCASE macros. Not everything needs to * be a constant, but it soothes the programmer's conscience to encapsulate @@ -1524,7 +1523,7 @@ static void connect_init(struct daemon *daemon, const u8 *msg) announcable))); #if DEVELOPER if (dev_disconnect) - dev_disconnect_init(6); + dev_disconnect_init(5); #endif } @@ -1998,7 +1997,7 @@ int main(int argc, char *argv[]) status_setup_async(daemon->master); /* This streams gossip to and from gossipd */ - daemon->gossipd = daemon_conn_new(daemon, GOSSIPCTL2_FD, + daemon->gossipd = daemon_conn_new(daemon, GOSSIPCTL_FD, recv_gossip, NULL, daemon); diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index f733bbbc4707..a22bd87fd8c9 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -114,7 +114,7 @@ void peer_supplied_good_gossip(struct peer *peer, size_t amount) void queue_peer_msg(struct peer *peer, const u8 *msg TAKES) { u8 *outermsg = towire_gossipd_send_gossip(NULL, &peer->id, msg); - daemon_conn_send(peer->daemon->connectd2, take(outermsg)); + daemon_conn_send(peer->daemon->connectd, take(outermsg)); if (taken(msg)) tal_free(msg); @@ -530,27 +530,6 @@ static struct io_plan *connectd_req(struct io_conn *conn, { enum connectd_gossipd_wire t = fromwire_peektype(msg); - switch (t) { - /* This is not for this fd! */ - case WIRE_GOSSIPD_RECV_GOSSIP: - case WIRE_GOSSIPD_NEW_PEER: - case WIRE_GOSSIPD_PEER_GONE: - /* We send these, don't receive them. */ - case WIRE_GOSSIPD_SEND_GOSSIP: - break; - } - - status_failed(STATUS_FAIL_INTERNAL_ERROR, - "Bad msg from connectd: %s", tal_hex(tmpctx, msg)); -} - -/*~ connectd's input handler is very simple. */ -static struct io_plan *connectd_gossip_req(struct io_conn *conn, - const u8 *msg, - struct daemon *daemon) -{ - enum connectd_gossipd_wire t = fromwire_peektype(msg); - switch (t) { case WIRE_GOSSIPD_RECV_GOSSIP: handle_recv_gossip(daemon, msg); @@ -573,7 +552,7 @@ static struct io_plan *connectd_gossip_req(struct io_conn *conn, "Bad msg from connectd2: %s", tal_hex(tmpctx, msg)); handled: - return daemon_conn_read_next(conn, daemon->connectd2); + return daemon_conn_read_next(conn, daemon->connectd); } /* BOLT #7: @@ -731,14 +710,11 @@ static void gossip_init(struct daemon *daemon, const u8 *msg) /* Fire up the seeker! */ daemon->seeker = new_seeker(daemon); - /* connectd is already started, and uses this fd to ask us things. */ + /* connectd is already started, and uses this fd to feed/recv gossip. */ daemon->connectd = daemon_conn_new(daemon, CONNECTD_FD, connectd_req, maybe_send_query_responses, daemon); - daemon->connectd2 = daemon_conn_new(daemon, CONNECTD2_FD, - connectd_gossip_req, NULL, daemon); - /* OK, we are ready. */ daemon_conn_send(daemon->master, take(towire_gossipd_init_reply(NULL))); diff --git a/gossipd/gossipd.h b/gossipd/gossipd.h index 9a73c8974305..a84d5765eb71 100644 --- a/gossipd/gossipd.h +++ b/gossipd/gossipd.h @@ -33,7 +33,6 @@ struct daemon { /* Connection to connect daemon. */ struct daemon_conn *connectd; - struct daemon_conn *connectd2; /* Routing information */ struct routing_state *rstate; diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index 3adee5797431..0cb9e0ce3819 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -474,9 +474,9 @@ static void connect_init_done(struct subd *connectd, io_break(connectd); } -int connectd_init(struct lightningd *ld, int *gossipd_fd2) +int connectd_init(struct lightningd *ld) { - int fds[2], fds2[2]; + int fds[2]; u8 *msg; int hsmfd; struct wireaddr_internal *wireaddrs = ld->proposed_wireaddr; @@ -489,16 +489,11 @@ int connectd_init(struct lightningd *ld, int *gossipd_fd2) if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) fatal("Could not socketpair for connectd<->gossipd"); - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds2) != 0) - fatal("Could not socketpair for connectd<->gossipd 2"); - hsmfd = hsm_get_global_fd(ld, HSM_CAP_ECDH); ld->connectd = new_global_subd(ld, "lightning_connectd", connectd_wire_name, connectd_msg, - take(&hsmfd), - take(&fds[1]), - take(&fds2[1]), + take(&hsmfd), take(&fds[1]), #if DEVELOPER /* Not take(): we share it */ ld->dev_disconnect_fd >= 0 ? @@ -539,7 +534,6 @@ int connectd_init(struct lightningd *ld, int *gossipd_fd2) /* Wait for init_reply */ io_loop(NULL, NULL); - *gossipd_fd2 = fds2[0]; return fds[0]; } diff --git a/lightningd/connect_control.h b/lightningd/connect_control.h index 681c5c7a1ed5..67beb003782b 100644 --- a/lightningd/connect_control.h +++ b/lightningd/connect_control.h @@ -7,7 +7,7 @@ struct pubkey; struct wireaddr_internal; /* Returns fd for gossipd to talk to connectd */ -int connectd_init(struct lightningd *ld, int *gossipd_fd2); +int connectd_init(struct lightningd *ld); void connectd_activate(struct lightningd *ld); void try_reconnect(struct channel *channel, u32 seconds_delay, diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 7429d4db3a89..e16607345b24 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -234,7 +234,7 @@ static void gossipd_init_done(struct subd *gossipd, /* Create the `gossipd` subdaemon and send the initialization * message */ -void gossip_init(struct lightningd *ld, int connectd_fd, int connectd_fd2) +void gossip_init(struct lightningd *ld, int connectd_fd) { u8 *msg; int hsmfd; @@ -243,10 +243,7 @@ void gossip_init(struct lightningd *ld, int connectd_fd, int connectd_fd2) ld->gossip = new_global_subd(ld, "lightning_gossipd", gossipd_wire_name, gossip_msg, - take(&hsmfd), - take(&connectd_fd), - take(&connectd_fd2), - NULL); + take(&hsmfd), take(&connectd_fd), NULL); if (!ld->gossip) err(1, "Could not subdaemon gossip"); diff --git a/lightningd/gossip_control.h b/lightningd/gossip_control.h index 869f53930aaf..c1d587902158 100644 --- a/lightningd/gossip_control.h +++ b/lightningd/gossip_control.h @@ -8,7 +8,7 @@ struct channel; struct lightningd; -void gossip_init(struct lightningd *ld, int connectd_fd, int connectd_fd2); +void gossip_init(struct lightningd *ld, int connectd_fd); void gossipd_notify_spend(struct lightningd *ld, const struct short_channel_id *scid); diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index bc0d97f649a2..621d4f9e3dcd 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -847,7 +847,7 @@ int main(int argc, char *argv[]) { struct lightningd *ld; u32 min_blockheight, max_blockheight; - int connectd_gossipd_fd, connectd_gossipd_fd2; + int connectd_gossipd_fd; int stop_fd; struct timers *timers; const char *stop_response; @@ -1019,7 +1019,7 @@ int main(int argc, char *argv[]) * which knows (via node_announcement messages) the public * addresses of nodes, so connectd_init hands it one end of a * socket pair, and gives us the other */ - connectd_gossipd_fd = connectd_init(ld, &connectd_gossipd_fd2); + connectd_gossipd_fd = connectd_init(ld); /*~ We do every database operation within a transaction; usually this * is covered by the infrastructure (eg. opening a transaction before @@ -1071,7 +1071,7 @@ int main(int argc, char *argv[]) * channel_announcement, channel_update, node_announcement and gossip * queries. It also hands us the latest channel_updates for our * channels. */ - gossip_init(ld, connectd_gossipd_fd, connectd_gossipd_fd2); + gossip_init(ld, connectd_gossipd_fd); /*~ Create RPC socket: now lightning-cli can send us JSON RPC commands * over a UNIX domain socket specified by `ld->rpc_filename`. */ diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c index 9d80d7bc3e76..94b20455b75b 100644 --- a/lightningd/test/run-find_my_abspath.c +++ b/lightningd/test/run-find_my_abspath.c @@ -23,7 +23,7 @@ void channel_notify_new_block(struct lightningd *ld UNNEEDED, void connectd_activate(struct lightningd *ld UNNEEDED) { fprintf(stderr, "connectd_activate called!\n"); abort(); } /* Generated stub for connectd_init */ -int connectd_init(struct lightningd *ld UNNEEDED, int *gossipd_fd2 UNNEEDED) +int connectd_init(struct lightningd *ld UNNEEDED) { fprintf(stderr, "connectd_init called!\n"); abort(); } /* Generated stub for daemon_poll */ int daemon_poll(struct pollfd *fds UNNEEDED, nfds_t nfds UNNEEDED, int timeout UNNEEDED) @@ -92,7 +92,7 @@ bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDE bool fromwire_status_version(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, wirestring **version UNNEEDED) { fprintf(stderr, "fromwire_status_version called!\n"); abort(); } /* Generated stub for gossip_init */ -void gossip_init(struct lightningd *ld UNNEEDED, int connectd_fd UNNEEDED, int connectd_fd2 UNNEEDED) +void gossip_init(struct lightningd *ld UNNEEDED, int connectd_fd UNNEEDED) { fprintf(stderr, "gossip_init called!\n"); abort(); } /* Generated stub for gossip_notify_new_block */ void gossip_notify_new_block(struct lightningd *ld UNNEEDED, u32 blockheight UNNEEDED)