For fast-forwarding to the given timestamp */
| 1982 | |
| 1983 | /* For fast-forwarding to the given timestamp */ |
| 1984 | void gossmap_iter_fast_forward(const struct gossmap *map, |
| 1985 | struct gossmap_iter *iter, |
| 1986 | u64 timestamp) |
| 1987 | { |
| 1988 | /* If we have reopened (unlikely!), we need to restart iteration */ |
| 1989 | if (iter->generation != map->generation) { |
| 1990 | iter->generation = map->generation; |
| 1991 | iter->offset = 1; |
| 1992 | } |
| 1993 | |
| 1994 | while (iter->offset + sizeof(struct gossip_hdr) <= map->map_size) { |
| 1995 | struct gossip_hdr ghdr; |
| 1996 | |
| 1997 | map_copy(map, iter->offset, &ghdr, sizeof(ghdr)); |
| 1998 | |
| 1999 | if (be32_to_cpu(ghdr.timestamp) >= timestamp) |
| 2000 | break; |
| 2001 | |
| 2002 | iter->offset += be16_to_cpu(ghdr.len) + sizeof(ghdr); |
| 2003 | } |
| 2004 | } |
| 2005 | |
| 2006 | void gossmap_iter_end(const struct gossmap *map, struct gossmap_iter *iter) |
| 2007 | { |
no test coverage detected