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

Function main

gossipd/gossipd.c:587–626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585}
586
587int main(int argc, char *argv[])
588{
589 struct daemon *daemon;
590 bool developer;
591
592 setup_locale();
593
594 developer = subdaemon_setup(argc, argv);
595
596 daemon = tal(NULL, struct daemon);
597 daemon->developer = developer;
598 daemon->peers = new_htable(daemon, peer_node_id_map);
599 daemon->deferred_txouts = tal_arr(daemon, struct short_channel_id, 0);
600 daemon->current_blockheight = 0; /* i.e. unknown */
601
602 /* Note the use of time_mono() here. That's a monotonic clock, which
603 * is really useful: it can only be used to measure relative events
604 * (there's no correspondence to time-since-Ken-grew-a-beard or
605 * anything), but unlike time_now, this will never jump backwards by
606 * half a second and leave me wondering how my tests failed CI! */
607 timers_init(&daemon->timers, time_mono());
608
609 /* Our daemons always use STDIN for commands from lightningd. */
610 daemon->master = daemon_conn_new(daemon, STDIN_FILENO,
611 recv_req, NULL, daemon);
612 tal_add_destructor(daemon->master, master_or_connectd_gone);
613
614 status_setup_async(daemon->master);
615
616 /* This loop never exits. io_loop() only returns if a timer has
617 * expired, or io_break() is called, or all fds are closed. We don't
618 * use io_break and closing the lightningd fd calls master_gone()
619 * which exits. */
620 for (;;) {
621 struct timer *expired = NULL;
622 io_loop(&daemon->timers, &expired);
623
624 timer_expired(expired);
625 }
626}
627
628/*~ Note that the production of the gossip_store file is in gossmap_manage.c
629 * and gossip_store.c, and the (highly optimized!) read side is in

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected