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

This commit is contained in:
Péter Szilágyi 2018-01-02 12:38:26 +02:00 committed by Felix Lange
parent 2fe07c203e
commit 9c42a41ed8
1 changed files with 4 additions and 1 deletions

View File

@ -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: