From b35165555d737042d5f958413827c31a7a5f4805 Mon Sep 17 00:00:00 2001
From: Wenbiao Zheng <delweng@gmail.com>
Date: Wed, 7 Nov 2018 07:30:19 -0600
Subject: [PATCH] eth/downloader: remove the expired id directly (#17963)

---
 eth/downloader/queue.go | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index c6b635aff..863cc8de1 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -664,12 +664,11 @@ func (q *queue) expire(timeout time.Duration, pendPool map[string]*fetchRequest,
 			}
 			// Add the peer to the expiry report along the number of failed requests
 			expiries[id] = len(request.Headers)
+
+			// Remove the expired requests from the pending pool directly
+			delete(pendPool, id)
 		}
 	}
-	// Remove the expired requests from the pending pool
-	for id := range expiries {
-		delete(pendPool, id)
-	}
 	return expiries
 }
 
-- 
GitLab