Create the `gossipd` subdaemon and send the initialization * message */
| 302 | /* Create the `gossipd` subdaemon and send the initialization |
| 303 | * message */ |
| 304 | void gossip_init(struct lightningd *ld, int connectd_fd) |
| 305 | { |
| 306 | u8 *msg; |
| 307 | void *ret; |
| 308 | |
| 309 | ld->gossip = new_global_subd(ld, "lightning_gossipd", |
| 310 | gossipd_wire_name, gossip_msg, |
| 311 | take(&connectd_fd), NULL); |
| 312 | if (!ld->gossip) |
| 313 | err(1, "Could not subdaemon gossip"); |
| 314 | |
| 315 | /* We haven't started topology yet, so tell us when we're synced. */ |
| 316 | topology_add_sync_waiter(ld->gossip, ld->topology, |
| 317 | gossip_topology_synced, NULL); |
| 318 | |
| 319 | msg = towire_gossipd_init( |
| 320 | NULL, |
| 321 | chainparams, |
| 322 | ld->our_features, |
| 323 | &ld->our_nodeid, |
| 324 | ld->autoconnect_seeker_peers, |
| 325 | subdaemon_path(tmpctx, ld, "lightning_gossip_compactd"), |
| 326 | ld->dev_fast_gossip, |
| 327 | ld->dev_fast_gossip_prune); |
| 328 | |
| 329 | subd_req(ld->gossip, ld->gossip, take(msg), -1, 0, |
| 330 | gossipd_init_done, NULL); |
| 331 | |
| 332 | /* Wait for gossipd_init_reply */ |
| 333 | ret = io_loop(NULL, NULL); |
| 334 | log_debug(ld->log, "io_loop: %s", __func__); |
| 335 | assert(ret == ld->gossip); |
| 336 | } |
| 337 | |
| 338 | /* We save these so we always tell gossipd about new blockheight first. */ |
| 339 | void gossipd_notify_spends(struct lightningd *ld, |
no test coverage detected