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
8310bcda
Commit
8310bcda
authored
Apr 14, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
state: fixed mutex lockes
parent
474aa924
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
managed_state.go
core/state/managed_state.go
+14
-2
No files found.
core/state/managed_state.go
View file @
8310bcda
...
@@ -37,7 +37,7 @@ func (ms *ManagedState) SetState(statedb *StateDB) {
...
@@ -37,7 +37,7 @@ func (ms *ManagedState) SetState(statedb *StateDB) {
// RemoveNonce removed the nonce from the managed state and all future pending nonces
// RemoveNonce removed the nonce from the managed state and all future pending nonces
func
(
ms
*
ManagedState
)
RemoveNonce
(
addr
common
.
Address
,
n
uint64
)
{
func
(
ms
*
ManagedState
)
RemoveNonce
(
addr
common
.
Address
,
n
uint64
)
{
if
ms
.
H
asAccount
(
addr
)
{
if
ms
.
h
asAccount
(
addr
)
{
ms
.
mu
.
Lock
()
ms
.
mu
.
Lock
()
defer
ms
.
mu
.
Unlock
()
defer
ms
.
mu
.
Unlock
()
...
@@ -67,7 +67,10 @@ func (ms *ManagedState) NewNonce(addr common.Address) uint64 {
...
@@ -67,7 +67,10 @@ func (ms *ManagedState) NewNonce(addr common.Address) uint64 {
// GetNonce returns the canonical nonce for the managed or unmanged account
// GetNonce returns the canonical nonce for the managed or unmanged account
func
(
ms
*
ManagedState
)
GetNonce
(
addr
common
.
Address
)
uint64
{
func
(
ms
*
ManagedState
)
GetNonce
(
addr
common
.
Address
)
uint64
{
if
ms
.
HasAccount
(
addr
)
{
ms
.
mu
.
RLock
()
defer
ms
.
mu
.
RUnlock
()
if
ms
.
hasAccount
(
addr
)
{
account
:=
ms
.
getAccount
(
addr
)
account
:=
ms
.
getAccount
(
addr
)
return
uint64
(
len
(
account
.
nonces
))
+
account
.
nstart
return
uint64
(
len
(
account
.
nonces
))
+
account
.
nstart
}
else
{
}
else
{
...
@@ -77,6 +80,9 @@ func (ms *ManagedState) GetNonce(addr common.Address) uint64 {
...
@@ -77,6 +80,9 @@ func (ms *ManagedState) GetNonce(addr common.Address) uint64 {
// SetNonce sets the new canonical nonce for the managed state
// SetNonce sets the new canonical nonce for the managed state
func
(
ms
*
ManagedState
)
SetNonce
(
addr
common
.
Address
,
nonce
uint64
)
{
func
(
ms
*
ManagedState
)
SetNonce
(
addr
common
.
Address
,
nonce
uint64
)
{
ms
.
mu
.
Lock
()
defer
ms
.
mu
.
Unlock
()
so
:=
ms
.
GetOrNewStateObject
(
addr
)
so
:=
ms
.
GetOrNewStateObject
(
addr
)
so
.
SetNonce
(
nonce
)
so
.
SetNonce
(
nonce
)
...
@@ -85,6 +91,12 @@ func (ms *ManagedState) SetNonce(addr common.Address, nonce uint64) {
...
@@ -85,6 +91,12 @@ func (ms *ManagedState) SetNonce(addr common.Address, nonce uint64) {
// HasAccount returns whether the given address is managed or not
// HasAccount returns whether the given address is managed or not
func
(
ms
*
ManagedState
)
HasAccount
(
addr
common
.
Address
)
bool
{
func
(
ms
*
ManagedState
)
HasAccount
(
addr
common
.
Address
)
bool
{
ms
.
mu
.
RLock
()
defer
ms
.
mu
.
RUnlock
()
return
ms
.
hasAccount
(
addr
)
}
func
(
ms
*
ManagedState
)
hasAccount
(
addr
common
.
Address
)
bool
{
_
,
ok
:=
ms
.
accounts
[
addr
.
Str
()]
_
,
ok
:=
ms
.
accounts
[
addr
.
Str
()]
return
ok
return
ok
}
}
...
...
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