Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common/gossip_store: optimize case where entries are filtered out. #5328

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions common/gossip_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,16 @@ u8 *gossip_store_next(const tal_t *ctx,
continue;
}

checksum = be32_to_cpu(hdr.crc);
/* Skip any timestamp filtered */
timestamp = be32_to_cpu(hdr.timestamp);
if (!push &&
!timestamp_filter(timestamp_min, timestamp_max,
timestamp)) {
*off += r + msglen;
continue;
}

checksum = be32_to_cpu(hdr.crc);
msg = tal_arr(ctx, u8, msglen);
r = pread(*gossip_store_fd, msg, msglen, *off + r);
if (r != msglen)
Expand All @@ -105,10 +113,6 @@ u8 *gossip_store_next(const tal_t *ctx,
&& type != WIRE_CHANNEL_UPDATE
&& type != WIRE_NODE_ANNOUNCEMENT) {
msg = tal_free(msg);
} else if (!push &&
!timestamp_filter(timestamp_min, timestamp_max,
timestamp)) {
msg = tal_free(msg);
} else if (!push && push_only) {
msg = tal_free(msg);
}
Expand Down
4 changes: 2 additions & 2 deletions gossipd/gossip_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ static u32 gossip_store_compact_offline(struct routing_state *rstate)
oldlen = lseek(old_fd, SEEK_END, 0);
newlen = lseek(new_fd, SEEK_END, 0);
append_msg(old_fd, towire_gossip_store_ended(tmpctx, newlen),
0, false, &oldlen);
0, true, &oldlen);
close(old_fd);
status_debug("gossip_store_compact_offline: %zu deleted, %zu copied",
deleted, count);
Expand Down Expand Up @@ -565,7 +565,7 @@ bool gossip_store_compact(struct gossip_store *gs)

/* Write end marker now new one is ready */
append_msg(gs->fd, towire_gossip_store_ended(tmpctx, len),
0, false, &gs->len);
0, true, &gs->len);

gs->count = count;
gs->deleted = 0;
Expand Down