Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
fb8a3aaf
Unverified
Commit
fb8a3aaf
authored
Mar 28, 2023
by
s7v7nislands
Committed by
GitHub
Mar 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/state: use atomic.Bool (#26992)
parent
79532a25
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
difflayer.go
core/state/snapshot/difflayer.go
+3
-3
snapshot.go
core/state/snapshot/snapshot.go
+2
-3
No files found.
core/state/snapshot/difflayer.go
View file @
fb8a3aaf
...
...
@@ -103,7 +103,7 @@ type diffLayer struct {
memory
uint64
// Approximate guess as to how much memory we use
root
common
.
Hash
// Root hash to which this snapshot diff belongs to
stale
uint32
// Signals that the layer became stale (state progressed)
stale
atomic
.
Bool
// Signals that the layer became stale (state progressed)
// destructSet is a very special helper marker. If an account is marked as
// deleted, then it's recorded in this set. However it's allowed that an account
...
...
@@ -267,7 +267,7 @@ func (dl *diffLayer) Parent() snapshot {
// Stale return whether this layer has become stale (was flattened across) or if
// it's still live.
func
(
dl
*
diffLayer
)
Stale
()
bool
{
return
atomic
.
LoadUint32
(
&
dl
.
stale
)
!=
0
return
dl
.
stale
.
Load
()
}
// Account directly retrieves the account associated with a particular hash in
...
...
@@ -449,7 +449,7 @@ func (dl *diffLayer) flatten() snapshot {
// Before actually writing all our data to the parent, first ensure that the
// parent hasn't been 'corrupted' by someone else already flattening into it
if
atomic
.
SwapUint32
(
&
parent
.
stale
,
1
)
!=
0
{
if
parent
.
stale
.
Swap
(
true
)
{
panic
(
"parent diff layer is stale"
)
// we've flattened into the same parent from two children, boo
}
// Overwrite all the updated accounts blindly, merge the sorted list
...
...
core/state/snapshot/snapshot.go
View file @
fb8a3aaf
...
...
@@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"sync"
"sync/atomic"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
...
...
@@ -272,7 +271,7 @@ func (t *Tree) Disable() {
case
*
diffLayer
:
// If the layer is a simple diff, simply mark as stale
layer
.
lock
.
Lock
()
atomic
.
StoreUint32
(
&
layer
.
stale
,
1
)
layer
.
stale
.
Store
(
true
)
layer
.
lock
.
Unlock
()
default
:
...
...
@@ -726,7 +725,7 @@ func (t *Tree) Rebuild(root common.Hash) {
case
*
diffLayer
:
// If the layer is a simple diff, simply mark as stale
layer
.
lock
.
Lock
()
atomic
.
StoreUint32
(
&
layer
.
stale
,
1
)
layer
.
stale
.
Store
(
true
)
layer
.
lock
.
Unlock
()
default
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment