gossipd: place limit on pending announcements.

Now we queue them, we should place a limit.  It's not the worst thing in
the world if we discard them (we'll catch up eventually), but we should
try not to in case we're just a bit behind.

Our behaviour here is also O(n^2) so we don't want a massive queue
anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-09-22 11:51:34 +09:30
parent fd2d74aa9b
commit a071a754b3
1 changed files with 14 additions and 0 deletions

View File

@ -1746,6 +1746,20 @@ u8 *handle_channel_announcement(struct routing_state *rstate,
goto malformed;
}
/* Don't add an infinite number of pending announcements. If we're
* catching up with the bitcoin chain, though, they can definitely
* pile up. */
if (pending_cannouncement_map_count(&rstate->pending_cannouncements)
> 100000) {
static bool warned = false;
if (!warned) {
status_unusual("Flooded by channel_announcements:"
" ignoring some");
warned = true;
}
goto ignored;
}
status_debug("Received channel_announcement for channel %s",
type_to_string(tmpctx, struct short_channel_id,
&pending->short_channel_id));