aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-03-16 19:12:46 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-16 19:12:46 +0800
commit138e7af96c2316f38f0ba8c7692253a7ad97ffba (patch)
tree67ad9e1d6ff43acf35cbc5073738806ea3f871d0 /eth
parent8b6ae6bf86091483a7514b272bafcf730def0200 (diff)
parent0228fb57cd58147ab2c3914520c7805e25a8a1c4 (diff)
downloadgo-tangerine-138e7af96c2316f38f0ba8c7692253a7ad97ffba.tar
go-tangerine-138e7af96c2316f38f0ba8c7692253a7ad97ffba.tar.gz
go-tangerine-138e7af96c2316f38f0ba8c7692253a7ad97ffba.tar.bz2
go-tangerine-138e7af96c2316f38f0ba8c7692253a7ad97ffba.tar.lz
go-tangerine-138e7af96c2316f38f0ba8c7692253a7ad97ffba.tar.xz
go-tangerine-138e7af96c2316f38f0ba8c7692253a7ad97ffba.tar.zst
go-tangerine-138e7af96c2316f38f0ba8c7692253a7ad97ffba.zip
Merge pull request #2354 from karalabe/miner-atomic-pending
eth, miner: fetch pending block/state in on go (data race)
Diffstat (limited to 'eth')
-rw-r--r--eth/api.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/eth/api.go b/eth/api.go
index 487d24ae7..c16c3d142 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -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)