MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

connectd/connectd.c:2512–2580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

setup_localeFunction · 0.85
timers_initFunction · 0.85
time_monoFunction · 0.85
status_setup_asyncFunction · 0.85
ecdh_hsmd_setupFunction · 0.85
io_set_extended_errorsFunction · 0.85
io_loopFunction · 0.85
timer_expiredFunction · 0.85
subdaemon_setupFunction · 0.50

Tested by

no test coverage detected