mirror of https://github.com/status-im/op-geth.git
eth: fix snap sync cancellation
This commit is contained in:
parent
6291fc9230
commit
bfdff4c5b8
|
@ -346,7 +346,6 @@ func (d *Downloader) Synchronise(id string, head common.Hash, td *big.Int, mode
|
|||
case nil, errBusy, errCanceled:
|
||||
return err
|
||||
}
|
||||
|
||||
if errors.Is(err, errInvalidChain) || errors.Is(err, errBadPeer) || errors.Is(err, errTimeout) ||
|
||||
errors.Is(err, errStallingPeer) || errors.Is(err, errUnsyncedPeer) || errors.Is(err, errEmptyHeaderSet) ||
|
||||
errors.Is(err, errPeersUnavailable) || errors.Is(err, errTooOld) || errors.Is(err, errInvalidAncestor) {
|
||||
|
@ -1764,7 +1763,7 @@ func (d *Downloader) processFastSyncContent() error {
|
|||
}()
|
||||
|
||||
closeOnErr := func(s *stateSync) {
|
||||
if err := s.Wait(); err != nil && err != errCancelStateFetch && err != errCanceled {
|
||||
if err := s.Wait(); err != nil && err != errCancelStateFetch && err != errCanceled && err != snap.ErrCancelled {
|
||||
d.queue.Close() // wake up Results
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ var (
|
|||
errDecode = errors.New("invalid message")
|
||||
errInvalidMsgCode = errors.New("invalid message code")
|
||||
errBadRequest = errors.New("bad request")
|
||||
errCancelled = errors.New("sync cancelled")
|
||||
)
|
||||
|
||||
// Packet represents a p2p message in the `snap` protocol.
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue