File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ type diffLayer struct {
103
103
memory uint64 // Approximate guess as to how much memory we use
104
104
105
105
root common.Hash // Root hash to which this snapshot diff belongs to
106
- stale uint32 // Signals that the layer became stale (state progressed)
106
+ stale atomic. Bool // Signals that the layer became stale (state progressed)
107
107
108
108
// destructSet is a very special helper marker. If an account is marked as
109
109
// deleted, then it's recorded in this set. However it's allowed that an account
@@ -267,7 +267,7 @@ func (dl *diffLayer) Parent() snapshot {
267
267
// Stale return whether this layer has become stale (was flattened across) or if
268
268
// it's still live.
269
269
func (dl * diffLayer ) Stale () bool {
270
- return atomic . LoadUint32 ( & dl .stale ) != 0
270
+ return dl .stale . Load ()
271
271
}
272
272
273
273
// Account directly retrieves the account associated with a particular hash in
@@ -449,7 +449,7 @@ func (dl *diffLayer) flatten() snapshot {
449
449
450
450
// Before actually writing all our data to the parent, first ensure that the
451
451
// parent hasn't been 'corrupted' by someone else already flattening into it
452
- if atomic . SwapUint32 ( & parent .stale , 1 ) != 0 {
452
+ if parent .stale . Swap ( true ) {
453
453
panic ("parent diff layer is stale" ) // we've flattened into the same parent from two children, boo
454
454
}
455
455
// Overwrite all the updated accounts blindly, merge the sorted list
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import (
22
22
"errors"
23
23
"fmt"
24
24
"sync"
25
- "sync/atomic"
26
25
27
26
"github.com/ethereum/go-ethereum/common"
28
27
"github.com/ethereum/go-ethereum/core/rawdb"
@@ -272,7 +271,7 @@ func (t *Tree) Disable() {
272
271
case * diffLayer :
273
272
// If the layer is a simple diff, simply mark as stale
274
273
layer .lock .Lock ()
275
- atomic . StoreUint32 ( & layer .stale , 1 )
274
+ layer .stale . Store ( true )
276
275
layer .lock .Unlock ()
277
276
278
277
default :
@@ -726,7 +725,7 @@ func (t *Tree) Rebuild(root common.Hash) {
726
725
case * diffLayer :
727
726
// If the layer is a simple diff, simply mark as stale
728
727
layer .lock .Lock ()
729
- atomic . StoreUint32 ( & layer .stale , 1 )
728
+ layer .stale . Store ( true )
730
729
layer .lock .Unlock ()
731
730
732
731
default :
You can’t perform that action at this time.
0 commit comments