eth/downloader: short circuit if nothing to delete

This commit is contained in:
Gary Rong 2023-12-12 10:47:51 +08:00
parent 75929ca3e4
commit de234dfe15

View file

@ -1125,6 +1125,10 @@ func (s *skeleton) cleanStales(filled *types.Header) error {
if number+1 < s.progress.Subchains[0].Tail { 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) 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 // 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 // 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 // filled one (it's expected to link with the filled one, otherwise