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

Function remove_all_gossip

gossipd/routing.c:2062–2100  ·  view source on GitHub ↗

Gossip store was corrupt, forget anything we loaded. */

Source from the content-addressed store, hash-verified

2060
2061/* Gossip store was corrupt, forget anything we loaded. */
2062void remove_all_gossip(struct routing_state *rstate)
2063{
2064 struct node *n;
2065 struct node_map_iter nit;
2066 struct chan *c;
2067 struct unupdated_channel *uc;
2068 u64 index;
2069 struct pending_cannouncement *pca;
2070 struct pending_cannouncement_map_iter pit;
2071 struct pending_node_map_iter pnait;
2072
2073 /* We don't want them to try to delete from store, so do this
2074 * manually. */
2075 while ((n = node_map_first(rstate->nodes, &nit)) != NULL) {
2076 tal_del_destructor2(n, destroy_node, rstate);
2077 if (node_uses_chan_map(n))
2078 chan_map_clear(&n->chans.map);
2079 node_map_del(rstate->nodes, n);
2080 tal_free(n);
2081 }
2082
2083 /* Now free all the channels. */
2084 while ((c = uintmap_first(&rstate->chanmap, &index)) != NULL) {
2085 uintmap_del(&rstate->chanmap, index);
2086#if DEVELOPER
2087 c->sat = amount_sat((unsigned long)c);
2088#endif
2089 tal_free(c);
2090 }
2091
2092 while ((uc = uintmap_first(&rstate->unupdated_chanmap, &index)) != NULL)
2093 tal_free(uc);
2094
2095 while ((pca = pending_cannouncement_map_first(&rstate->pending_cannouncements, &pit)) != NULL)
2096 tal_free(pca);
2097
2098 /* Freeing unupdated chanmaps should empty this */
2099 assert(pending_node_map_first(rstate->pending_node_map, &pnait) == NULL);
2100}
2101
2102static void channel_spent(struct routing_state *rstate,
2103 struct chan *chan STEALS)

Callers 1

gossip_store_loadFunction · 0.85

Calls 3

node_uses_chan_mapFunction · 0.85
tal_freeFunction · 0.85
amount_satClass · 0.70

Tested by

no test coverage detected