From a50251e6cbfecfaf26040d42c70d2812bc422a4a Mon Sep 17 00:00:00 2001 From: xD AKA Rapper King Of cn background diablo & revelations <33193253+r1cs@users.noreply.github.com> Date: Wed, 14 Apr 2021 18:44:32 +0800 Subject: [PATCH] eth/fetcher: avoid spurious timer events at startup (#22652) Co-authored-by: Felix Lange --- eth/fetcher/block_fetcher.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eth/fetcher/block_fetcher.go b/eth/fetcher/block_fetcher.go index 5ea8a128d..3177a877e 100644 --- a/eth/fetcher/block_fetcher.go +++ b/eth/fetcher/block_fetcher.go @@ -331,8 +331,12 @@ func (f *BlockFetcher) FilterBodies(peer string, transactions [][]*types.Transac // events. func (f *BlockFetcher) loop() { // Iterate the block fetching until a quit is requested - fetchTimer := time.NewTimer(0) - completeTimer := time.NewTimer(0) + var ( + fetchTimer = time.NewTimer(0) + completeTimer = time.NewTimer(0) + ) + <-fetchTimer.C // clear out the channel + <-completeTimer.C defer fetchTimer.Stop() defer completeTimer.Stop()