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

Function main

gossipd/gossipd.c:1082–1128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1080}
1081
1082int main(int argc, char *argv[])
1083{
1084 setup_locale();
1085
1086 struct daemon *daemon;
1087
1088 subdaemon_setup(argc, argv);
1089
1090 daemon = tal(NULL, struct daemon);
1091 list_head_init(&daemon->peers);
1092 daemon->deferred_txouts = tal_arr(daemon, struct short_channel_id, 0);
1093 daemon->node_announce_timer = NULL;
1094 daemon->node_announce_regen_timer = NULL;
1095 daemon->current_blockheight = 0; /* i.e. unknown */
1096 daemon->rates = NULL;
1097 daemon->discovered_ip_v4 = NULL;
1098 daemon->discovered_ip_v6 = NULL;
1099 list_head_init(&daemon->deferred_updates);
1100
1101 /* Tell the ecdh() function how to talk to hsmd */
1102 ecdh_hsmd_setup(HSM_FD, status_failed);
1103
1104 /* Note the use of time_mono() here. That's a monotonic clock, which
1105 * is really useful: it can only be used to measure relative events
1106 * (there's no correspondence to time-since-Ken-grew-a-beard or
1107 * anything), but unlike time_now(), this will never jump backwards by
1108 * half a second and leave me wondering how my tests failed CI! */
1109 timers_init(&daemon->timers, time_mono());
1110
1111 /* Our daemons always use STDIN for commands from lightningd. */
1112 daemon->master = daemon_conn_new(daemon, STDIN_FILENO,
1113 recv_req, NULL, daemon);
1114 tal_add_destructor(daemon->master, master_or_connectd_gone);
1115
1116 status_setup_async(daemon->master);
1117
1118 /* This loop never exits. io_loop() only returns if a timer has
1119 * expired, or io_break() is called, or all fds are closed. We don't
1120 * use io_break and closing the lightningd fd calls master_gone()
1121 * which exits. */
1122 for (;;) {
1123 struct timer *expired = NULL;
1124 io_loop(&daemon->timers, &expired);
1125
1126 timer_expired(expired);
1127 }
1128}
1129
1130/*~ Note that the actual routing stuff is in routing.c; you might want to
1131 * check that out later.

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