forked from cerc-io/plugeth
ethdb/leveldb: use timer instead of time.After (#21066)
This commit is contained in:
parent
2f66a8d614
commit
7ddb40239b
@ -248,6 +248,9 @@ func (db *Database) meter(refresh time.Duration) {
|
|||||||
merr error
|
merr error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
timer := time.NewTimer(refresh)
|
||||||
|
defer timer.Stop()
|
||||||
|
|
||||||
// Iterate ad infinitum and collect the stats
|
// Iterate ad infinitum and collect the stats
|
||||||
for i := 1; errc == nil && merr == nil; i++ {
|
for i := 1; errc == nil && merr == nil; i++ {
|
||||||
// Retrieve the database stats
|
// Retrieve the database stats
|
||||||
@ -399,7 +402,8 @@ func (db *Database) meter(refresh time.Duration) {
|
|||||||
select {
|
select {
|
||||||
case errc = <-db.quitChan:
|
case errc = <-db.quitChan:
|
||||||
// Quit requesting, stop hammering the database
|
// Quit requesting, stop hammering the database
|
||||||
case <-time.After(refresh):
|
case <-timer.C:
|
||||||
|
timer.Reset(refresh)
|
||||||
// Timeout, gather a new set of stats
|
// Timeout, gather a new set of stats
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user