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
77787403
Commit
77787403
authored
May 18, 2015
by
Bas van Kervel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed race condition in miner
parent
67d44519
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
agent.go
miner/agent.go
+7
-12
No files found.
miner/agent.go
View file @
77787403
...
...
@@ -40,7 +40,6 @@ func (self *CpuAgent) Stop() {
defer
self
.
mu
.
Unlock
()
close
(
self
.
quit
)
close
(
self
.
quitCurrentOp
)
}
func
(
self
*
CpuAgent
)
Start
()
{
...
...
@@ -50,7 +49,6 @@ func (self *CpuAgent) Start() {
self
.
quit
=
make
(
chan
struct
{})
// creating current op ch makes sure we're not closing a nil ch
// later on
self
.
quitCurrentOp
=
make
(
chan
struct
{})
self
.
workCh
=
make
(
chan
*
types
.
Block
,
1
)
go
self
.
update
()
...
...
@@ -62,10 +60,12 @@ out:
select
{
case
block
:=
<-
self
.
workCh
:
self
.
mu
.
Lock
()
close
(
self
.
quitCurrentOp
)
if
self
.
quitCurrentOp
!=
nil
{
close
(
self
.
quitCurrentOp
)
}
self
.
quitCurrentOp
=
make
(
chan
struct
{})
go
self
.
mine
(
block
,
self
.
quitCurrentOp
)
self
.
mu
.
Unlock
()
go
self
.
mine
(
block
)
case
<-
self
.
quit
:
break
out
}
...
...
@@ -84,16 +84,11 @@ done:
}
}
func
(
self
*
CpuAgent
)
mine
(
block
*
types
.
Block
)
{
func
(
self
*
CpuAgent
)
mine
(
block
*
types
.
Block
,
stop
<-
chan
struct
{}
)
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"(re)started agent[%d]. mining...
\n
"
,
self
.
index
)
// Reset the channel
self
.
mu
.
Lock
()
self
.
quitCurrentOp
=
make
(
chan
struct
{})
self
.
mu
.
Unlock
()
// Mine
nonce
,
mixDigest
:=
self
.
pow
.
Search
(
block
,
s
elf
.
quitCurrentO
p
)
nonce
,
mixDigest
:=
self
.
pow
.
Search
(
block
,
s
to
p
)
if
nonce
!=
0
{
block
.
SetNonce
(
nonce
)
block
.
Header
()
.
MixDigest
=
common
.
BytesToHash
(
mixDigest
)
...
...
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