From 5866626b0896bafb74e140bc44ddd24ff9006d91 Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Tue, 2 Jan 2018 12:50:46 +0100 Subject: core, p2p/discv5: use time.NewTicker instead of time.Tick (#15747) --- core/blockchain.go | 5 +++-- p2p/discv5/database.go | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 325753c7a..812f9e562 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1196,10 +1196,11 @@ func (bc *BlockChain) PostChainEvents(events []interface{}, logs []*types.Log) { } func (bc *BlockChain) update() { - futureTimer := time.Tick(5 * time.Second) + futureTimer := time.NewTicker(5 * time.Second) + defer futureTimer.Stop() for { select { - case <-futureTimer: + case <-futureTimer.C: bc.procFutureBlocks() case <-bc.quit: return diff --git a/p2p/discv5/database.go b/p2p/discv5/database.go index a3b044ec1..3c2d5744c 100644 --- a/p2p/discv5/database.go +++ b/p2p/discv5/database.go @@ -239,14 +239,14 @@ func (db *nodeDB) ensureExpirer() { // expirer should be started in a go routine, and is responsible for looping ad // infinitum and dropping stale data from the database. func (db *nodeDB) expirer() { - tick := time.Tick(nodeDBCleanupCycle) + tick := time.NewTicker(nodeDBCleanupCycle) + defer tick.Stop() for { select { - case <-tick: + case <-tick.C: if err := db.expireNodes(); err != nil { log.Error(fmt.Sprintf("Failed to expire nodedb items: %v", err)) } - case <-db.quit: return } -- cgit