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
c841e394
Commit
c841e394
authored
Oct 31, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1954 from obscuren/regression-miner
miner: synchronise start / stop
parents
016ad3e9
8c38f8d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
remote_agent.go
miner/remote_agent.go
+12
-5
No files found.
miner/remote_agent.go
View file @
c841e394
...
...
@@ -20,6 +20,7 @@ import (
"errors"
"math/big"
"sync"
"sync/atomic"
"time"
"github.com/ethereum/ethash"
...
...
@@ -45,6 +46,8 @@ type RemoteAgent struct {
hashrateMu
sync
.
RWMutex
hashrate
map
[
common
.
Hash
]
hashrate
running
int32
// running indicates whether the agent is active. Call atomically
}
func
NewRemoteAgent
()
*
RemoteAgent
{
...
...
@@ -70,18 +73,22 @@ func (a *RemoteAgent) SetReturnCh(returnCh chan<- *Result) {
}
func
(
a
*
RemoteAgent
)
Start
()
{
if
!
atomic
.
CompareAndSwapInt32
(
&
a
.
running
,
0
,
1
)
{
return
}
a
.
quit
=
make
(
chan
struct
{})
a
.
workCh
=
make
(
chan
*
Work
,
1
)
go
a
.
maintainLoop
()
}
func
(
a
*
RemoteAgent
)
Stop
()
{
if
a
.
quit
!=
nil
{
close
(
a
.
quit
)
}
if
a
.
workCh
!=
nil
{
close
(
a
.
workCh
)
if
!
atomic
.
CompareAndSwapInt32
(
&
a
.
running
,
1
,
0
)
{
return
}
close
(
a
.
quit
)
close
(
a
.
workCh
)
}
// GetHashRate returns the accumulated hashrate of all identifier combined
...
...
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