Revert "eth/downloader: drop beacon head updates if the syncer is restarting (#27397)"

This reverts commit 0968b3d498.
This commit is contained in:
devopsbo3 2023-11-10 12:27:53 -06:00 committed by GitHub
parent cbd9ba5c6f
commit 5422e21986

View file

@ -367,31 +367,13 @@ func (s *skeleton) sync(head *types.Header) (*types.Header, error) {
s.filler.resume() s.filler.resume()
} }
defer func() { defer func() {
// The filler needs to be suspended, but since it can block for a while if filled := s.filler.suspend(); filled != nil {
// when there are many blocks queued up for full-sync importing, run it // If something was filled, try to delete stale sync helpers. If
// on a separate goroutine and consume head messages that need instant // unsuccessful, warn the user, but not much else we can do (it's
// replies. // a programming error, just let users report an issue and don't
done := make(chan struct{}) // choke in the meantime).
go func() { if err := s.cleanStales(filled); err != nil {
defer close(done) log.Error("Failed to clean stale beacon headers", "err", err)
if filled := s.filler.suspend(); filled != nil {
// If something was filled, try to delete stale sync helpers. If
// unsuccessful, warn the user, but not much else we can do (it's
// a programming error, just let users report an issue and don't
// choke in the meantime).
if err := s.cleanStales(filled); err != nil {
log.Error("Failed to clean stale beacon headers", "err", err)
}
}
}()
// Wait for the suspend to finish, consuming head events in the meantime
// and dropping them on the floor.
for {
select {
case <-done:
return
case event := <-s.headEvents:
event.errc <- errors.New("beacon syncer reorging")
} }
} }
}() }()