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
eb6cbe37
Unverified
Commit
eb6cbe37
authored
1 year ago
by
Martin Holst Swende
Committed by
GitHub
1 year ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/state: remove public method ForEachStorage (#27986)
Co-authored-by:
Felix Lange
<
fjl@twurst.com
>
parent
2f4dbb4f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
41 deletions
+40
-41
statedb.go
core/state/statedb.go
+0
-39
statedb_test.go
core/state/statedb_test.go
+40
-2
No files found.
core/state/statedb.go
View file @
eb6cbe37
...
...
@@ -32,8 +32,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/trienode"
"github.com/ethereum/go-ethereum/trie/triestate"
)
...
...
@@ -722,43 +720,6 @@ func (s *StateDB) CreateAccount(addr common.Address) {
}
}
func
(
s
*
StateDB
)
ForEachStorage
(
addr
common
.
Address
,
cb
func
(
key
,
value
common
.
Hash
)
bool
)
error
{
so
:=
s
.
getStateObject
(
addr
)
if
so
==
nil
{
return
nil
}
tr
,
err
:=
so
.
getTrie
()
if
err
!=
nil
{
return
err
}
trieIt
,
err
:=
tr
.
NodeIterator
(
nil
)
if
err
!=
nil
{
return
err
}
it
:=
trie
.
NewIterator
(
trieIt
)
for
it
.
Next
()
{
key
:=
common
.
BytesToHash
(
s
.
trie
.
GetKey
(
it
.
Key
))
if
value
,
dirty
:=
so
.
dirtyStorage
[
key
];
dirty
{
if
!
cb
(
key
,
value
)
{
return
nil
}
continue
}
if
len
(
it
.
Value
)
>
0
{
_
,
content
,
_
,
err
:=
rlp
.
Split
(
it
.
Value
)
if
err
!=
nil
{
return
err
}
if
!
cb
(
key
,
common
.
BytesToHash
(
content
))
{
return
nil
}
}
}
return
nil
}
// Copy creates a deep, independent copy of the state.
// Snapshots of the copied state cannot be applied to the copy.
func
(
s
*
StateDB
)
Copy
()
*
StateDB
{
...
...
This diff is collapsed.
Click to expand it.
core/state/statedb_test.go
View file @
eb6cbe37
...
...
@@ -35,6 +35,7 @@ import (
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"
"github.com/ethereum/go-ethereum/trie/triedb/pathdb"
...
...
@@ -447,6 +448,43 @@ func (test *snapshotTest) run() bool {
return
true
}
func
forEachStorage
(
s
*
StateDB
,
addr
common
.
Address
,
cb
func
(
key
,
value
common
.
Hash
)
bool
)
error
{
so
:=
s
.
getStateObject
(
addr
)
if
so
==
nil
{
return
nil
}
tr
,
err
:=
so
.
getTrie
()
if
err
!=
nil
{
return
err
}
trieIt
,
err
:=
tr
.
NodeIterator
(
nil
)
if
err
!=
nil
{
return
err
}
it
:=
trie
.
NewIterator
(
trieIt
)
for
it
.
Next
()
{
key
:=
common
.
BytesToHash
(
s
.
trie
.
GetKey
(
it
.
Key
))
if
value
,
dirty
:=
so
.
dirtyStorage
[
key
];
dirty
{
if
!
cb
(
key
,
value
)
{
return
nil
}
continue
}
if
len
(
it
.
Value
)
>
0
{
_
,
content
,
_
,
err
:=
rlp
.
Split
(
it
.
Value
)
if
err
!=
nil
{
return
err
}
if
!
cb
(
key
,
common
.
BytesToHash
(
content
))
{
return
nil
}
}
}
return
nil
}
// checkEqual checks that methods of state and checkstate return the same values.
func
(
test
*
snapshotTest
)
checkEqual
(
state
,
checkstate
*
StateDB
)
error
{
for
_
,
addr
:=
range
test
.
addrs
{
...
...
@@ -468,10 +506,10 @@ func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
checkeq
(
"GetCodeSize"
,
state
.
GetCodeSize
(
addr
),
checkstate
.
GetCodeSize
(
addr
))
// Check storage.
if
obj
:=
state
.
getStateObject
(
addr
);
obj
!=
nil
{
state
.
ForEachStorage
(
addr
,
func
(
key
,
value
common
.
Hash
)
bool
{
forEachStorage
(
state
,
addr
,
func
(
key
,
value
common
.
Hash
)
bool
{
return
checkeq
(
"GetState("
+
key
.
Hex
()
+
")"
,
checkstate
.
GetState
(
addr
,
key
),
value
)
})
checkstate
.
ForEachStorage
(
addr
,
func
(
key
,
value
common
.
Hash
)
bool
{
forEachStorage
(
checkstate
,
addr
,
func
(
key
,
value
common
.
Hash
)
bool
{
return
checkeq
(
"GetState("
+
key
.
Hex
()
+
")"
,
checkstate
.
GetState
(
addr
,
key
),
value
)
})
}
...
...
This diff is collapsed.
Click to expand it.
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