ethdb/leveldb: use timer instead of time.After (#21066)

release/1.9
ucwong 5 years ago committed by GitHub
parent 2f66a8d614
commit 7ddb40239b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      ethdb/leveldb/leveldb.go

@ -248,6 +248,9 @@ func (db *Database) meter(refresh time.Duration) {
merr error
)
timer := time.NewTimer(refresh)
defer timer.Stop()
// Iterate ad infinitum and collect the stats
for i := 1; errc == nil && merr == nil; i++ {
// Retrieve the database stats
@ -399,7 +402,8 @@ func (db *Database) meter(refresh time.Duration) {
select {
case errc = <-db.quitChan:
// Quit requesting, stop hammering the database
case <-time.After(refresh):
case <-timer.C:
timer.Reset(refresh)
// Timeout, gather a new set of stats
}
}

Loading…
Cancel
Save