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

Function new_routing_state

gossipd/routing.c:286–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286struct routing_state *new_routing_state(const tal_t *ctx,
287 const struct node_id *local_id,
288 struct list_head *peers,
289 struct timers *timers,
290 const u32 *dev_gossip_time TAKES,
291 bool dev_fast_gossip,
292 bool dev_fast_gossip_prune)
293{
294 struct routing_state *rstate = tal(ctx, struct routing_state);
295 rstate->nodes = new_node_map(rstate);
296 rstate->timers = timers;
297 rstate->local_id = *local_id;
298 rstate->gs = gossip_store_new(rstate, peers);
299 rstate->local_channel_announced = false;
300 rstate->last_timestamp = 0;
301 rstate->dying_channels = tal_arr(rstate, struct dying_channel, 0);
302
303 pending_cannouncement_map_init(&rstate->pending_cannouncements);
304
305 uintmap_init(&rstate->chanmap);
306 uintmap_init(&rstate->unupdated_chanmap);
307 rstate->num_txout_failures = 0;
308 uintmap_init(&rstate->txout_failures);
309 uintmap_init(&rstate->txout_failures_old);
310 txout_failure_age(rstate);
311 rstate->pending_node_map = tal(ctx, struct pending_node_map);
312 pending_node_map_init(rstate->pending_node_map);
313
314#if DEVELOPER
315 if (dev_gossip_time) {
316 rstate->gossip_time = tal(rstate, struct timeabs);
317 rstate->gossip_time->ts.tv_sec = *dev_gossip_time;
318 rstate->gossip_time->ts.tv_nsec = 0;
319 } else
320 rstate->gossip_time = NULL;
321 rstate->dev_fast_gossip = dev_fast_gossip;
322 rstate->dev_fast_gossip_prune = dev_fast_gossip_prune;
323#endif
324 tal_add_destructor(rstate, destroy_routing_state);
325 memleak_add_helper(rstate, memleak_help_routing_tables);
326
327 if (taken(dev_gossip_time))
328 tal_free(dev_gossip_time);
329
330 return rstate;
331}
332
333
334const struct node_id *node_map_keyof_node(const struct node *n)

Callers 2

gossip_initFunction · 0.85
mainFunction · 0.85

Calls 5

new_node_mapFunction · 0.85
txout_failure_ageFunction · 0.85
takenFunction · 0.85
tal_freeFunction · 0.85
gossip_store_newFunction · 0.70

Tested by 1

mainFunction · 0.68