eth: fix snap sync cancellation

This commit is contained in:
Péter Szilágyi
2021-02-16 16:11:33 +02:00
parent 6291fc9230
commit bfdff4c5b8
3 changed files with 6 additions and 4 deletions

View File

@ -88,6 +88,10 @@ var (
requestTimeout = 10 * time.Second // TODO(karalabe): Make it dynamic ala fast-sync?
)
// ErrCancelled is returned from snap syncing if the operation was prematurely
// terminated.
var ErrCancelled = errors.New("sync cancelled")
// accountRequest tracks a pending account range request to ensure responses are
// to actual requests and to validate any security constraints.
//
@ -615,7 +619,7 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error {
case id := <-peerDrop:
s.revertRequests(id)
case <-cancel:
return errCancelled
return ErrCancelled
case req := <-s.accountReqFails:
s.revertAccountRequest(req)