core, p2p/discv5: use time.NewTicker instead of time.Tick (#15747)

This commit is contained in:
ferhat elmas 2018-01-02 12:50:46 +01:00 committed by Felix Lange
parent c495bca4ad
commit 5866626b08
2 changed files with 6 additions and 5 deletions

View File

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

View File

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