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

Function map_copy

common/gossmap.c:107–131  ·  view source on GitHub ↗

Accessors for the gossmap */

Source from the content-addressed store, hash-verified

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

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