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

Function map_copy

common/gossmap.c:104–128  ·  view source on GitHub ↗

Accessors for the gossmap */

Source from the content-addressed store, hash-verified

102
103/* Accessors for the gossmap */
104static void map_copy(const struct gossmap *map, u64 offset,
105 void *dst, size_t len)
106{
107 /* After mmap, we place local channel_announcements then channel_updates */
108 if (offset >= map->map_size) {
109 u64 localannoff = offset - map->map_size;
110 if (localannoff < tal_bytelen(map->local_announces)) {
111 assert(localannoff + len <= tal_bytelen(map->local_announces));
112 memcpy(dst, map->local_announces + localannoff, len);
113 } else {
114 u64 localchanoff = localannoff - tal_bytelen(map->local_announces);
115 assert(localchanoff + len <= tal_bytelen(map->local_updates));
116 memcpy(dst, map->local_updates + localchanoff, len);
117 }
118 } else {
119 assert(offset + len <= map->map_size);
120 if (map->mmap)
121 memcpy(dst, map->mmap + offset, len);
122 else {
123 /* Yeah, we'll crash on I/O errors. */
124 if (pread(map->fd, dst, len, offset) != len)
125 abort();
126 }
127 }
128}
129
130static u8 map_u8(const struct gossmap *map, u64 offset)
131{

Callers 15

map_u8Function · 0.85
map_be16Function · 0.85
map_be32Function · 0.85
map_be64Function · 0.85
map_nodeidFunction · 0.85
report_dying_cbFunction · 0.85
reopen_storeFunction · 0.85
map_catchupFunction · 0.85
gossmap_chan_is_dyingFunction · 0.85

Calls 2

tal_bytelenFunction · 0.85
abortFunction · 0.85

Tested by

no test coverage detected