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

Function main

connectd/connectd.c:2011–2056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2009#endif /* DEVELOPER */
2010
2011int main(int argc, char *argv[])
2012{
2013 setup_locale();
2014
2015 struct daemon *daemon;
2016
2017 /* Common subdaemon setup code. */
2018 subdaemon_setup(argc, argv);
2019
2020 /* Allocate and set up our simple top-level structure. */
2021 daemon = tal(NULL, struct daemon);
2022 daemon->connection_counter = 1;
2023 peer_htable_init(&daemon->peers);
2024 memleak_add_helper(daemon, memleak_daemon_cb);
2025 list_head_init(&daemon->connecting);
2026 timers_init(&daemon->timers, time_mono());
2027 daemon->gossip_store_fd = -1;
2028
2029 /* stdin == control */
2030 daemon->master = daemon_conn_new(daemon, STDIN_FILENO, recv_req, NULL,
2031 daemon);
2032 tal_add_destructor(daemon->master, master_gone);
2033
2034 /* This tells the status_* subsystem to use this connection to send
2035 * our status_ and failed messages. */
2036 status_setup_async(daemon->master);
2037
2038 /* Don't leave around websocketd zombies. Technically not portable,
2039 * but OK for Linux and BSD, so... */
2040 signal(SIGCHLD, SIG_IGN);
2041
2042 /* This streams gossip to and from gossipd */
2043 daemon->gossipd = daemon_conn_new(daemon, GOSSIPCTL_FD,
2044 recv_gossip, NULL,
2045 daemon);
2046
2047 /* Set up ecdh() function so it uses our HSM fd, and calls
2048 * status_failed on error. */
2049 ecdh_hsmd_setup(HSM_FD, status_failed);
2050
2051 for (;;) {
2052 struct timer *expired;
2053 io_loop(&daemon->timers, &expired);
2054 timer_expired(expired);
2055 }
2056}
2057
2058/*~ Getting bored? This was a pretty simple daemon!
2059 *

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected