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

Function gossip_init

gossipd/gossipd.c:715–775  ·  view source on GitHub ↗

~ Parse init message from lightningd: starts the daemon properly. */

Source from the content-addressed store, hash-verified

713
714/*~ Parse init message from lightningd: starts the daemon properly. */
715static void gossip_init(struct daemon *daemon, const u8 *msg)
716{
717 u32 *dev_gossip_time;
718 bool dev_fast_gossip, dev_fast_gossip_prune;
719 u32 timestamp;
720
721 if (!fromwire_gossipd_init(daemon, msg,
722 &chainparams,
723 &daemon->our_features,
724 &daemon->id,
725 daemon->rgb,
726 daemon->alias,
727 &daemon->announceable,
728 &dev_gossip_time,
729 &dev_fast_gossip,
730 &dev_fast_gossip_prune)) {
731 master_badmsg(WIRE_GOSSIPD_INIT, msg);
732 }
733
734 daemon->rstate = new_routing_state(daemon,
735 &daemon->id,
736 &daemon->peers,
737 &daemon->timers,
738 take(dev_gossip_time),
739 dev_fast_gossip,
740 dev_fast_gossip_prune);
741
742 /* Load stored gossip messages, get last modified time of file */
743 timestamp = gossip_store_load(daemon->rstate, daemon->rstate->gs);
744
745 /* If last_timestamp was > modified time of file, reduce it.
746 * Usually it's capped to "now", but in the reload case it needs to
747 * be the gossip_store mtime. */
748 if (daemon->rstate->last_timestamp > timestamp)
749 daemon->rstate->last_timestamp = timestamp;
750
751 /* Now disable all local channels, they can't be connected yet. */
752 gossip_disable_local_channels(daemon);
753
754 /* If that announced channels, we can announce ourselves (options
755 * or addresses might have changed!) */
756 maybe_send_own_node_announce(daemon, true);
757
758 /* Start the twice- weekly refresh timer. */
759 notleak(new_reltimer(&daemon->timers, daemon,
760 time_from_sec(GOSSIP_PRUNE_INTERVAL(daemon->rstate->dev_fast_gossip_prune) / 4),
761 gossip_refresh_network, daemon));
762
763 /* Fire up the seeker! */
764 daemon->seeker = new_seeker(daemon);
765
766 /* connectd is already started, and uses this fd to feed/recv gossip. */
767 daemon->connectd = daemon_conn_new(daemon, CONNECTD_FD,
768 connectd_req,
769 maybe_send_query_responses, daemon);
770 tal_add_destructor(daemon->connectd, master_or_connectd_gone);
771
772 /* OK, we are ready. */

Callers 1

recv_reqFunction · 0.70

Calls 8

new_routing_stateFunction · 0.85
gossip_store_loadFunction · 0.85
time_from_secFunction · 0.85
new_seekerFunction · 0.85
master_badmsgFunction · 0.50
daemon_conn_sendFunction · 0.50

Tested by

no test coverage detected