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
dadd6893
Unverified
Commit
dadd6893
authored
Dec 13, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
miner: fix data race on setting etherbase/extradata
parent
b750cab5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
miner.go
miner/miner.go
+6
-10
worker.go
miner/worker.go
+6
-0
No files found.
miner/miner.go
View file @
dadd6893
...
...
@@ -119,15 +119,14 @@ func (m *Miner) SetGasPrice(price *big.Int) {
func
(
self
*
Miner
)
Start
(
coinbase
common
.
Address
,
threads
int
)
{
atomic
.
StoreInt32
(
&
self
.
shouldStart
,
1
)
self
.
threads
=
threads
self
.
worker
.
coinbase
=
coinbase
self
.
worker
.
setEtherbase
(
coinbase
)
self
.
coinbase
=
coinbase
self
.
threads
=
threads
if
atomic
.
LoadInt32
(
&
self
.
canStart
)
==
0
{
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Can not start mining operation due to network sync (starts when finished)"
)
return
}
atomic
.
StoreInt32
(
&
self
.
mining
,
1
)
for
i
:=
0
;
i
<
threads
;
i
++
{
...
...
@@ -135,9 +134,7 @@ func (self *Miner) Start(coinbase common.Address, threads int) {
}
glog
.
V
(
logger
.
Info
)
.
Infof
(
"Starting mining operation (CPU=%d TOT=%d)
\n
"
,
threads
,
len
(
self
.
worker
.
agents
))
self
.
worker
.
start
()
self
.
worker
.
commitNewWork
()
}
...
...
@@ -177,8 +174,7 @@ func (self *Miner) SetExtra(extra []byte) error {
if
uint64
(
len
(
extra
))
>
params
.
MaximumExtraDataSize
.
Uint64
()
{
return
fmt
.
Errorf
(
"Extra exceeds max length. %d > %v"
,
len
(
extra
),
params
.
MaximumExtraDataSize
)
}
self
.
worker
.
extra
=
extra
self
.
worker
.
setExtra
(
extra
)
return
nil
}
...
...
@@ -188,9 +184,9 @@ func (self *Miner) Pending() (*types.Block, *state.StateDB) {
}
// PendingBlock returns the currently pending block.
//
// Note, to access both the pending block and the pending state
// simultaneously, please use Pending(), as the pending state can
//
// Note, to access both the pending block and the pending state
// simultaneously, please use Pending(), as the pending state can
// change between multiple method calls
func
(
self
*
Miner
)
PendingBlock
()
*
types
.
Block
{
return
self
.
worker
.
pendingBlock
()
...
...
miner/worker.go
View file @
dadd6893
...
...
@@ -161,6 +161,12 @@ func (self *worker) setEtherbase(addr common.Address) {
self
.
coinbase
=
addr
}
func
(
self
*
worker
)
setExtra
(
extra
[]
byte
)
{
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
self
.
extra
=
extra
}
func
(
self
*
worker
)
pending
()
(
*
types
.
Block
,
*
state
.
StateDB
)
{
self
.
currentMu
.
Lock
()
defer
self
.
currentMu
.
Unlock
()
...
...
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