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 {
103103	memory  uint64      // Approximate guess as to how much memory we use 
104104
105105	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) 
107107
108108	// destructSet is a very special helper marker. If an account is marked as 
109109	// deleted, then it's recorded in this set. However it's allowed that an account 
@@ -267,7 +267,7 @@ func (dl *diffLayer) Parent() snapshot {
267267// Stale return whether this layer has become stale (was flattened across) or if 
268268// it's still live. 
269269func  (dl  * diffLayer ) Stale () bool  {
270- 	return  atomic . LoadUint32 ( & dl .stale )  !=   0 
270+ 	return  dl .stale . Load () 
271271}
272272
273273// Account directly retrieves the account associated with a particular hash in 
@@ -449,7 +449,7 @@ func (dl *diffLayer) flatten() snapshot {
449449
450450	// Before actually writing all our data to the parent, first ensure that the 
451451	// 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 )  {
453453		panic ("parent diff layer is stale" ) // we've flattened into the same parent from two children, boo 
454454	}
455455	// 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 (
2222	"errors" 
2323	"fmt" 
2424	"sync" 
25- 	"sync/atomic" 
2625
2726	"github.com/ethereum/go-ethereum/common" 
2827	"github.com/ethereum/go-ethereum/core/rawdb" 
@@ -272,7 +271,7 @@ func (t *Tree) Disable() {
272271		case  * diffLayer :
273272			// If the layer is a simple diff, simply mark as stale 
274273			layer .lock .Lock ()
275- 			atomic . StoreUint32 ( & layer .stale ,  1 )
274+ 			layer .stale . Store ( true )
276275			layer .lock .Unlock ()
277276
278277		default :
@@ -726,7 +725,7 @@ func (t *Tree) Rebuild(root common.Hash) {
726725		case  * diffLayer :
727726			// If the layer is a simple diff, simply mark as stale 
728727			layer .lock .Lock ()
729- 			atomic . StoreUint32 ( & layer .stale ,  1 )
728+ 			layer .stale . Store ( true )
730729			layer .lock .Unlock ()
731730
732731		default :
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments