Create the `gossipd` subdaemon and send the initialization * message */
| 235 | /* Create the `gossipd` subdaemon and send the initialization |
| 236 | * message */ |
| 237 | void gossip_init(struct lightningd *ld, int connectd_fd) |
| 238 | { |
| 239 | u8 *msg; |
| 240 | int hsmfd; |
| 241 | void *ret; |
| 242 | |
| 243 | hsmfd = hsm_get_global_fd(ld, HSM_CAP_ECDH|HSM_CAP_SIGN_GOSSIP); |
| 244 | |
| 245 | ld->gossip = new_global_subd(ld, "lightning_gossipd", |
| 246 | gossipd_wire_name, gossip_msg, |
| 247 | take(&hsmfd), take(&connectd_fd), NULL); |
| 248 | if (!ld->gossip) |
| 249 | err(1, "Could not subdaemon gossip"); |
| 250 | |
| 251 | /* We haven't started topology yet, so tell us when we're synced. */ |
| 252 | topology_add_sync_waiter(ld->gossip, ld->topology, |
| 253 | gossip_topology_synced, NULL); |
| 254 | |
| 255 | msg = towire_gossipd_init( |
| 256 | NULL, |
| 257 | chainparams, |
| 258 | ld->our_features, |
| 259 | &ld->id, |
| 260 | ld->rgb, |
| 261 | ld->alias, |
| 262 | ld->announceable, |
| 263 | IFDEV(ld->dev_gossip_time ? &ld->dev_gossip_time: NULL, NULL), |
| 264 | IFDEV(ld->dev_fast_gossip, false), |
| 265 | IFDEV(ld->dev_fast_gossip_prune, false)); |
| 266 | |
| 267 | subd_req(ld->gossip, ld->gossip, take(msg), -1, 0, |
| 268 | gossipd_init_done, NULL); |
| 269 | |
| 270 | /* Wait for gossipd_init_reply */ |
| 271 | ret = io_loop(NULL, NULL); |
| 272 | log_debug(ld->log, "io_loop: %s", __func__); |
| 273 | assert(ret == ld->gossip); |
| 274 | } |
| 275 | |
| 276 | /* We save these so we always tell gossipd about new blockheight first. */ |
| 277 | void gossipd_notify_spends(struct lightningd *ld, |
no test coverage detected