ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
46.66k stars 19.67k forks source link

core/rawdb: use go ticker instead of timer #30054

Closed htiennv closed 6 days ago

lilasxie commented 1 week ago

Sorry for bothering you, but what's the benefit of the replacement?

jwasinger commented 6 days ago

Sorry for bothering you, but what's the benefit of the replacement?

The Ticker will fire multiple times without having to be explicitly Reset to do so.

htiennv commented 6 days ago

I don't think ticker is correct here. We don't want to fire events a regularly scheduled intervals. In the backoff, the goal is to wait freezerRecheckInterval time before resuming execution. To do this, should prefer a timer.

The code there actually seems incorrect, I believe the timer.Reset should be above the select in the backoff if statement.

Yeah, Thanks @lightclient for your review.