| 2503 | } |
| 2504 | |
| 2505 | int main(int argc, char *argv[]) |
| 2506 | { |
| 2507 | struct daemon *daemon; |
| 2508 | bool developer; |
| 2509 | |
| 2510 | setup_locale(); |
| 2511 | |
| 2512 | /* Common subdaemon setup code. */ |
| 2513 | developer = subdaemon_setup(argc, argv); |
| 2514 | |
| 2515 | /* Allocate and set up our simple top-level structure. */ |
| 2516 | daemon = tal(NULL, struct daemon); |
| 2517 | daemon->developer = developer; |
| 2518 | daemon->connection_counter = 1; |
| 2519 | /* htable_new is our helper which allocates a htable, initializes it |
| 2520 | * and set up the memleak callback so our memleak code can see objects |
| 2521 | * inside it */ |
| 2522 | daemon->peers = new_htable(daemon, peer_htable); |
| 2523 | daemon->listeners = tal_arr(daemon, struct io_listener *, 0); |
| 2524 | daemon->connecting = new_htable(daemon, connecting_htable); |
| 2525 | daemon->important_ids = new_htable(daemon, important_id_htable); |
| 2526 | timers_init(&daemon->timers, time_mono()); |
| 2527 | daemon->gossmap_raw = NULL; |
| 2528 | daemon->shutting_down = false; |
| 2529 | daemon->max_connect_in_flight = 10; |
| 2530 | daemon->dev_suppress_gossip = false; |
| 2531 | daemon->custom_msgs = NULL; |
| 2532 | daemon->dev_exhausted_fds = false; |
| 2533 | daemon->dev_lightningd_is_slow = false; |
| 2534 | daemon->dev_keep_nagle = false; |
| 2535 | /* We generally allow 1MB per second per peer, except for dev testing */ |
| 2536 | daemon->gossip_stream_limit = 1000000; |
| 2537 | daemon->incoming_stream_limit = 1000000; |
| 2538 | daemon->scid_htable = new_htable(daemon, scid_htable); |
| 2539 | |
| 2540 | /* stdin == control */ |
| 2541 | daemon->master = daemon_conn_new(daemon, STDIN_FILENO, recv_req, NULL, |
| 2542 | daemon); |
| 2543 | tal_add_destructor(daemon->master, master_gone); |
| 2544 | |
| 2545 | /* This tells the status_* subsystem to use this connection to send |
| 2546 | * our status_ and failed messages. */ |
| 2547 | status_setup_async(daemon->master); |
| 2548 | |
| 2549 | /* Don't leave around websocketd zombies. Technically not portable, |
| 2550 | * but OK for Linux and BSD, so... */ |
| 2551 | signal(SIGCHLD, SIG_IGN); |
| 2552 | |
| 2553 | /* This streams gossip to and from gossipd */ |
| 2554 | daemon->gossipd = daemon_conn_new(daemon, GOSSIPCTL_FD, |
| 2555 | recv_gossip, NULL, |
| 2556 | daemon); |
| 2557 | tal_add_destructor(daemon->gossipd, gossipd_failed); |
| 2558 | |
| 2559 | /* Set up ecdh() function so it uses our HSM fd, and calls |
| 2560 | * status_failed on error. */ |
| 2561 | ecdh_hsmd_setup(HSM_FD, status_failed); |
| 2562 |
nothing calls this directly
no test coverage detected