Skip to content

Commit 0f76a1c

Browse files
committed
core: changed how head events are checked
1 parent 580bae0 commit 0f76a1c

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎core/chain_manager.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
593593
self.setTransState(state.New(block.Root(), self.stateDb))
594594
self.txState.SetState(state.New(block.Root(), self.stateDb))
595595

596-
queue[i] = ChainEvent{block, logs}
596+
queue[i] = ChainEvent{block, block.Hash(), logs}
597597
queueEvent.canonicalCount++
598598

599599
if glog.V(logger.Debug) {
@@ -683,7 +683,7 @@ out:
683683
case ChainEvent:
684684
// We need some control over the mining operation. Acquiring locks and waiting for the miner to create new block takes too long
685685
// and in most cases isn't even necessary.
686-
if i+1 == ev.canonicalCount {
686+
if self.lastBlockHash == event.Hash {
687687
self.currentGasLimit = CalcGasLimit(event.Block)
688688
self.eventMux.Post(ChainHeadEvent{event.Block})
689689
}

‎core/events.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package core
33
import (
44
"math/big"
55

6+
"github.com/ethereum/go-ethereum/common"
67
"github.com/ethereum/go-ethereum/core/state"
78
"github.com/ethereum/go-ethereum/core/types"
89
)
@@ -27,6 +28,7 @@ type ChainSplitEvent struct {
2728

2829
type ChainEvent struct {
2930
Block *types.Block
31+
Hash common.Hash
3032
Logs state.Logs
3133
}
3234

0 commit comments

Comments
 (0)