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
677796b3
Commit
677796b3
authored
May 18, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1031 from bas-vk/issue1012
fixed race condition in miner
parents
67d44519
60561cdc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
agent.go
miner/agent.go
+13
-12
No files found.
miner/agent.go
View file @
677796b3
...
...
@@ -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,11 +60,19 @@ out:
select
{
case
block
:=
<-
self
.
workCh
:
self
.
mu
.
Lock
()
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
:
self
.
mu
.
Lock
()
if
self
.
quitCurrentOp
!=
nil
{
close
(
self
.
quitCurrentOp
)
self
.
quitCurrentOp
=
nil
}
self
.
mu
.
Unlock
()
break
out
}
}
...
...
@@ -84,16 +90,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