|
|
|
@ -367,6 +367,13 @@ func (s *skeleton) sync(head *types.Header) (*types.Header, error) { |
|
|
|
|
s.filler.resume() |
|
|
|
|
} |
|
|
|
|
defer func() { |
|
|
|
|
// The filler needs to be suspended, but since it can block for a while
|
|
|
|
|
// when there are many blocks queued up for full-sync importing, run it
|
|
|
|
|
// on a separate goroutine and consume head messages that need instant
|
|
|
|
|
// replies.
|
|
|
|
|
done := make(chan struct{}) |
|
|
|
|
go func() { |
|
|
|
|
defer close(done) |
|
|
|
|
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
|
|
|
|
@ -377,6 +384,17 @@ func (s *skeleton) sync(head *types.Header) (*types.Header, error) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}() |
|
|
|
|
// 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") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}() |
|
|
|
|
// Create a set of unique channels for this sync cycle. We need these to be
|
|
|
|
|
// ephemeral so a data race doesn't accidentally deliver something stale on
|
|
|
|
|
// a persistent channel across syncs (yup, this happened)
|
|
|
|
|