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

Function new_lightningd

lightningd/lightningd.c:91–386  ·  view source on GitHub ↗

~ The core lightning object: it's passed everywhere, and is basically a * global variable. This new_xxx pattern is something we'll see often: * it allocates and initializes a new structure, using *tal*, the hierarchical * allocator. */

Source from the content-addressed store, hash-verified

89 * it allocates and initializes a new structure, using *tal*, the hierarchical
90 * allocator. */
91static struct lightningd *new_lightningd(const tal_t *ctx)
92{
93 /*~ tal: each allocation is a child of an existing object (or NULL,
94 * the top-level object). When an object is freed, all the objects
95 * `tallocated` off it are also freed. We use it in place of malloc
96 * and free. For the technically inclined: tal allocations usually
97 * build a tree, and tal_freeing any node in the tree will result in
98 * the entire subtree rooted at that node to be freed.
99 *
100 * It's incredibly useful for grouping object lifetimes, as we'll see.
101 * For example, a `struct lightningd` has a pointer to a `log_book`
102 * which is allocated off the `struct lightningd`, and has its own
103 * internal members allocated off `log_book`: freeing `struct
104 * lightningd` frees them all.
105 *
106 * In this case, freeing `ctx` will free `ld`:
107 */
108 struct lightningd *ld = tal(ctx, struct lightningd);
109
110 /*~ Style note: `ctx` is declared `const`, yet we can `tallocate` from
111 * it. Adding/removing children is not considered to change an
112 * object; nor, in fact, is freeing it with tal_free(). This allows
113 * us to use const more liberally: the style rule here is that you
114 * should use 'const' on pointers if you can. */
115
116 /* They can turn this on with --developer */
117 ld->developer = false;
118
119 /*~ We used to EXPLICITLY #if-wrap DEVELOPER code, but as our test
120 * matrix grew, we turned them into a --developer runtime option.
121 * We still use the `dev` prefix everywhere to make the developer-
122 * only variations explicit though. */
123 ld->dev_debug_subprocess = NULL;
124 ld->dev_no_plugin_checksum = false;
125 ld->dev_disconnect_fd = -1;
126 ld->dev_subdaemon_fail = false;
127 ld->dev_allow_localhost = false;
128 ld->dev_fast_gossip = false;
129 ld->dev_fast_gossip_prune = false;
130 ld->dev_throttle_gossip = false;
131 ld->dev_suppress_gossip = false;
132 ld->dev_fast_reconnect = false;
133 ld->dev_reject_closing_fee = false;
134 ld->dev_force_privkey = NULL;
135 ld->dev_force_bip32_seed = NULL;
136 ld->dev_force_channel_secrets = NULL;
137 ld->dev_force_channel_secrets_shaseed = NULL;
138 ld->dev_force_tmp_channel_id = NULL;
139 ld->dev_no_htlc_timeout = false;
140 ld->dev_no_version_checks = false;
141 ld->dev_max_funding_unconfirmed = 2016;
142 ld->dev_max_dualopen_negotiation_secs = 600;
143 ld->dev_low_prio_anchor_blocks = 2016;
144 ld->dev_ignore_modern_onion = false;
145 ld->dev_disable_commit = -1;
146 ld->dev_no_ping_timer = false;
147 ld->dev_any_channel_type = false;
148 ld->dev_allow_shutdown_destination_change = false;

Callers 1

mainFunction · 0.85

Calls 8

list_head_initFunction · 0.85
timers_initFunction · 0.85
time_monoFunction · 0.85
new_log_bookFunction · 0.70
new_loggerFunction · 0.70
new_topologyFunction · 0.70
jsonrpc_setupFunction · 0.70
plugins_newFunction · 0.70

Tested by

no test coverage detected