From de234dfe15b85cb0b1491ae6909d89085084521e Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Tue, 12 Dec 2023 10:47:51 +0800 Subject: [PATCH] eth/downloader: short circuit if nothing to delete --- eth/downloader/skeleton.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eth/downloader/skeleton.go b/eth/downloader/skeleton.go index c4012f0bd7..9674e00054 100644 --- a/eth/downloader/skeleton.go +++ b/eth/downloader/skeleton.go @@ -1125,6 +1125,10 @@ func (s *skeleton) cleanStales(filled *types.Header) error { if number+1 < s.progress.Subchains[0].Tail { return fmt.Errorf("filled header below beacon header tail: %d < %d", number, s.progress.Subchains[0].Tail) } + // If nothing is filled, don't bother to do cleanup. + if number+1 == s.progress.Subchains[0].Tail { + return nil + } // Determine the new tail based on the given filled header. If it's still // in the range of skeleton chain, use the next header adjacent to the // filled one (it's expected to link with the filled one, otherwise