Skip to content

Commit ab70c17

Browse files
committed
stop and close iterator
Signed-off-by: jsvisa <[email protected]>
1 parent 7038bd9 commit ab70c17

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

core/state/statesize.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type stateSizeGenerator struct {
6161

6262
// Generator state
6363
running bool
64-
abort chan chan struct{}
64+
abort chan struct{}
6565
done chan struct{}
6666

6767
// Metrics state
@@ -74,7 +74,7 @@ func newStateSizeGenerator(db ethdb.KeyValueStore, sdb Database, root common.Has
7474
return &stateSizeGenerator{
7575
db: db,
7676
sdb: sdb,
77-
abort: make(chan chan struct{}),
77+
abort: make(chan struct{}),
7878
done: make(chan struct{}),
7979
metrics: &StateSizeMetrics{Root: root},
8080
}
@@ -95,9 +95,7 @@ func (g *stateSizeGenerator) stop() {
9595
if !g.running {
9696
return
9797
}
98-
ch := make(chan struct{})
99-
g.abort <- ch
100-
<-ch
98+
close(g.abort)
10199
g.running = false
102100
}
103101

@@ -156,10 +154,9 @@ func (g *stateSizeGenerator) initializeMetrics() {
156154
count++
157155
bytes += uint64(len(iter.Key()) + len(iter.Value()))
158156

159-
// Check for abort
160157
select {
161-
case abort := <-g.abort:
162-
close(abort)
158+
case <-g.abort:
159+
return
163160
default:
164161
}
165162
}

0 commit comments

Comments
 (0)