@@ -70,10 +70,10 @@ const (
7070// freezer is an memory mapped append-only database to store immutable chain data
7171// into flat files:
7272//
73- // - The append only nature ensures that disk writes are minimized.
74- // - The memory mapping ensures we can max out system memory for caching without
75- // reserving it for go-ethereum. This would also reduce the memory requirements
76- // of Geth, and thus also GC overhead.
73+ // - The append only nature ensures that disk writes are minimized.
74+ // - The memory mapping ensures we can max out system memory for caching without
75+ // reserving it for go-ethereum. This would also reduce the memory requirements
76+ // of Geth, and thus also GC overhead.
7777type freezer struct {
7878 // WARNING: The `frozen` field is accessed atomically. On 32 bit platforms, only
7979 // 64-bit aligned fields can be atomic. The struct is guaranteed to be so aligned,
@@ -205,9 +205,9 @@ func (f *freezer) Ancient(kind string, number uint64) ([]byte, error) {
205205
206206// AncientRange retrieves multiple items in sequence, starting from the index 'start'.
207207// It will return
208- // - at most 'max' items,
209- // - at least 1 item (even if exceeding the maxByteSize), but will otherwise
210- // return as many items as fit into maxByteSize.
208+ // - at most 'max' items,
209+ // - at least 1 item (even if exceeding the maxByteSize), but will otherwise
210+ // return as many items as fit into maxByteSize.
211211func (f * freezer ) AncientRange (kind string , start , count , maxBytes uint64 ) ([][]byte , error ) {
212212 if table := f .tables [kind ]; table != nil {
213213 return table .RetrieveItems (start , count , maxBytes )
@@ -339,6 +339,8 @@ func (f *freezer) freeze(db ethdb.KeyValueStore) {
339339 backoff bool
340340 triggered chan struct {} // Used in tests
341341 )
342+ timer := time .NewTimer (freezerRecheckInterval )
343+ defer timer .Stop ()
342344 for {
343345 select {
344346 case <- f .quit :
@@ -353,8 +355,9 @@ func (f *freezer) freeze(db ethdb.KeyValueStore) {
353355 triggered = nil
354356 }
355357 select {
356- case <- time . NewTimer ( freezerRecheckInterval ) .C :
358+ case <- timer .C :
357359 backoff = false
360+ timer .Reset (freezerRecheckInterval )
358361 case triggered = <- f .trigger :
359362 backoff = false
360363 case <- f .quit :
0 commit comments