Explorar o código

eth/downloader: avoid hidden reference to finished statesync request (#15545)

Péter Szilágyi %!s(int64=7) %!d(string=hai) anos
pai
achega
9c42a41ed8
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      eth/downloader/statesync.go

+ 4 - 1
eth/downloader/statesync.go

@@ -132,7 +132,10 @@ func (d *Downloader) runStateSync(s *stateSync) *stateSync {
 
 		// Send the next finished request to the current sync:
 		case deliverReqCh <- deliverReq:
-			finished = append(finished[:0], finished[1:]...)
+			// Shift out the first request, but also set the emptied slot to nil for GC
+			copy(finished, finished[1:])
+			finished[len(finished)-1] = nil
+			finished = finished[:len(finished)-1]
 
 		// Handle incoming state packs:
 		case pack := <-d.stateCh: