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
138e7af9
Commit
138e7af9
authored
Mar 16, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2354 from karalabe/miner-atomic-pending
eth, miner: fetch pending block/state in on go (data race)
parents
8b6ae6bf
0228fb57
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
17 deletions
+10
-17
api.go
eth/api.go
+4
-2
miner.go
miner/miner.go
+3
-6
worker.go
miner/worker.go
+3
-9
No files found.
eth/api.go
View file @
138e7af9
...
...
@@ -56,7 +56,8 @@ const defaultGas = uint64(90000)
func
blockByNumber
(
m
*
miner
.
Miner
,
bc
*
core
.
BlockChain
,
blockNr
rpc
.
BlockNumber
)
*
types
.
Block
{
// Pending block is only known by the miner
if
blockNr
==
rpc
.
PendingBlockNumber
{
return
m
.
PendingBlock
()
block
,
_
:=
m
.
Pending
()
return
block
}
// Otherwise resolve and return the block
if
blockNr
==
rpc
.
LatestBlockNumber
{
...
...
@@ -72,7 +73,8 @@ func blockByNumber(m *miner.Miner, bc *core.BlockChain, blockNr rpc.BlockNumber)
func
stateAndBlockByNumber
(
m
*
miner
.
Miner
,
bc
*
core
.
BlockChain
,
blockNr
rpc
.
BlockNumber
,
chainDb
ethdb
.
Database
)
(
*
state
.
StateDB
,
*
types
.
Block
,
error
)
{
// Pending state is only known by the miner
if
blockNr
==
rpc
.
PendingBlockNumber
{
return
m
.
PendingState
(),
m
.
PendingBlock
(),
nil
block
,
state
:=
m
.
Pending
()
return
state
,
block
,
nil
}
// Otherwise resolve the block number and return its state
block
:=
blockByNumber
(
m
,
bc
,
blockNr
)
...
...
miner/miner.go
View file @
138e7af9
...
...
@@ -164,12 +164,9 @@ func (self *Miner) SetExtra(extra []byte) error {
return
nil
}
func
(
self
*
Miner
)
PendingState
()
*
state
.
StateDB
{
return
self
.
worker
.
pendingState
()
}
func
(
self
*
Miner
)
PendingBlock
()
*
types
.
Block
{
return
self
.
worker
.
pendingBlock
()
// Pending returns the currently pending block and associated state.
func
(
self
*
Miner
)
Pending
()
(
*
types
.
Block
,
*
state
.
StateDB
)
{
return
self
.
worker
.
pending
()
}
func
(
self
*
Miner
)
SetEtherbase
(
addr
common
.
Address
)
{
...
...
miner/worker.go
View file @
138e7af9
...
...
@@ -152,13 +152,7 @@ func (self *worker) setEtherbase(addr common.Address) {
self
.
coinbase
=
addr
}
func
(
self
*
worker
)
pendingState
()
*
state
.
StateDB
{
self
.
currentMu
.
Lock
()
defer
self
.
currentMu
.
Unlock
()
return
self
.
current
.
state
}
func
(
self
*
worker
)
pendingBlock
()
*
types
.
Block
{
func
(
self
*
worker
)
pending
()
(
*
types
.
Block
,
*
state
.
StateDB
)
{
self
.
currentMu
.
Lock
()
defer
self
.
currentMu
.
Unlock
()
...
...
@@ -168,9 +162,9 @@ func (self *worker) pendingBlock() *types.Block {
self
.
current
.
txs
,
nil
,
self
.
current
.
receipts
,
)
)
,
self
.
current
.
state
}
return
self
.
current
.
Block
return
self
.
current
.
Block
,
self
.
current
.
state
}
func
(
self
*
worker
)
start
()
{
...
...
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