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
3c836dd7
Commit
3c836dd7
authored
Oct 05, 2016
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/state: optimize GetState
There is no need to use the reflection-based decoder to decode []byte.
parent
90fce8bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
state_object.go
core/state/state_object.go
+7
-5
No files found.
core/state/state_object.go
View file @
3c836dd7
...
@@ -153,10 +153,13 @@ func (self *StateObject) GetState(db trie.Database, key common.Hash) common.Hash
...
@@ -153,10 +153,13 @@ func (self *StateObject) GetState(db trie.Database, key common.Hash) common.Hash
return
value
return
value
}
}
// Load from DB in case it is missing.
// Load from DB in case it is missing.
tr
:=
self
.
getTrie
(
db
)
if
enc
:=
self
.
getTrie
(
db
)
.
Get
(
key
[
:
]);
len
(
enc
)
>
0
{
var
ret
[]
byte
_
,
content
,
_
,
err
:=
rlp
.
Split
(
enc
)
rlp
.
DecodeBytes
(
tr
.
Get
(
key
[
:
]),
&
ret
)
if
err
!=
nil
{
value
=
common
.
BytesToHash
(
ret
)
self
.
setError
(
err
)
}
value
.
SetBytes
(
content
)
}
if
(
value
!=
common
.
Hash
{})
{
if
(
value
!=
common
.
Hash
{})
{
self
.
cachedStorage
[
key
]
=
value
self
.
cachedStorage
[
key
]
=
value
}
}
...
@@ -209,7 +212,6 @@ func (self *StateObject) updateRoot(db trie.Database) {
...
@@ -209,7 +212,6 @@ func (self *StateObject) updateRoot(db trie.Database) {
func
(
self
*
StateObject
)
CommitTrie
(
db
trie
.
Database
,
dbw
trie
.
DatabaseWriter
)
error
{
func
(
self
*
StateObject
)
CommitTrie
(
db
trie
.
Database
,
dbw
trie
.
DatabaseWriter
)
error
{
self
.
updateTrie
(
db
)
self
.
updateTrie
(
db
)
if
self
.
dbErr
!=
nil
{
if
self
.
dbErr
!=
nil
{
fmt
.
Println
(
"dbErr:"
,
self
.
dbErr
)
return
self
.
dbErr
return
self
.
dbErr
}
}
root
,
err
:=
self
.
trie
.
CommitTo
(
dbw
)
root
,
err
:=
self
.
trie
.
CommitTo
(
dbw
)
...
...
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