Skip to content

Commit 0d42d32

Browse files
r1csfjl
authored andcommitted
eth/fetcher: avoid spurious timer events at startup (ethereum#22652)
Co-authored-by: Felix Lange <[email protected]>
1 parent 16dd0d8 commit 0d42d32

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

eth/fetcher/block_fetcher.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,12 @@ func (f *BlockFetcher) FilterBodies(peer string, transactions [][]*types.Transac
331331
// events.
332332
func (f *BlockFetcher) loop() {
333333
// Iterate the block fetching until a quit is requested
334-
fetchTimer := time.NewTimer(0)
335-
completeTimer := time.NewTimer(0)
334+
var (
335+
fetchTimer = time.NewTimer(0)
336+
completeTimer = time.NewTimer(0)
337+
)
338+
<-fetchTimer.C // clear out the channel
339+
<-completeTimer.C
336340
defer fetchTimer.Stop()
337341
defer completeTimer.Stop()
338342

0 commit comments

Comments
 (0)