| 937 | } |
| 938 | |
| 939 | static bool load_gossip_store(struct gossmap *map, |
| 940 | void (*dyingcb)(struct short_channel_id scid, |
| 941 | u32 blockheight, |
| 942 | u64 offset, |
| 943 | void *cb_arg), |
| 944 | void *cb_arg, |
| 945 | bool must_be_clean) |
| 946 | { |
| 947 | bool updated; |
| 948 | |
| 949 | map->map_size = lseek(map->fd, 0, SEEK_END); |
| 950 | map->local_announces = NULL; |
| 951 | map->local_updates = NULL; |
| 952 | |
| 953 | /* If this fails, we fall back to read */ |
| 954 | map->mmap = mmap(NULL, map->map_size, PROT_READ, MAP_SHARED, map->fd, 0); |
| 955 | if (map->mmap == MAP_FAILED) |
| 956 | map->mmap = NULL; |
| 957 | |
| 958 | /* We only support major version 0 */ |
| 959 | if (GOSSIP_STORE_MAJOR_VERSION(map_u8(map, 0)) != 0) { |
| 960 | map->logcb(map->cbarg, LOG_BROKEN, |
| 961 | "Unknown gossip_store version %u", map_u8(map, 0)); |
| 962 | errno = EINVAL; |
| 963 | return false; |
| 964 | } |
| 965 | |
| 966 | init_map_structs(map); |
| 967 | |
| 968 | map->map_end = 1; |
| 969 | return map_catchup(map, dyingcb, cb_arg, must_be_clean, &updated); |
| 970 | } |
| 971 | |
| 972 | static void destroy_map(struct gossmap *map) |
| 973 | { |
no test coverage detected