Gossip store was corrupt, forget anything we loaded. */
| 2060 | |
| 2061 | /* Gossip store was corrupt, forget anything we loaded. */ |
| 2062 | void 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 | |
| 2102 | static void channel_spent(struct routing_state *rstate, |
| 2103 | struct chan *chan STEALS) |
no test coverage detected