mirror of https://github.com/status-im/op-geth.git
better block propagation
This commit is contained in:
parent
7b8a47f484
commit
0ee0094cc0
|
@ -8,11 +8,11 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -523,7 +523,7 @@ out:
|
||||||
case ChainEvent:
|
case ChainEvent:
|
||||||
// We need some control over the mining operation. Acquiring locks and waiting for the miner to create new block takes too long
|
// We need some control over the mining operation. Acquiring locks and waiting for the miner to create new block takes too long
|
||||||
// and in most cases isn't even necessary.
|
// and in most cases isn't even necessary.
|
||||||
if i == ev.canonicalCount {
|
if i+1 == ev.canonicalCount {
|
||||||
self.eventMux.Post(ChainHeadEvent{event.Block})
|
self.eventMux.Post(ChainHeadEvent{event.Block})
|
||||||
}
|
}
|
||||||
case ChainSplitEvent:
|
case ChainSplitEvent:
|
||||||
|
|
|
@ -355,7 +355,7 @@ func (s *Ethereum) Start() error {
|
||||||
go s.txBroadcastLoop()
|
go s.txBroadcastLoop()
|
||||||
|
|
||||||
// broadcast mined blocks
|
// broadcast mined blocks
|
||||||
s.blockSub = s.eventMux.Subscribe(core.NewMinedBlockEvent{})
|
s.blockSub = s.eventMux.Subscribe(core.ChainHeadEvent{})
|
||||||
go s.blockBroadcastLoop()
|
go s.blockBroadcastLoop()
|
||||||
|
|
||||||
servlogger.Infoln("Server started")
|
servlogger.Infoln("Server started")
|
||||||
|
@ -421,7 +421,7 @@ func (self *Ethereum) blockBroadcastLoop() {
|
||||||
// automatically stops if unsubscribe
|
// automatically stops if unsubscribe
|
||||||
for obj := range self.blockSub.Chan() {
|
for obj := range self.blockSub.Chan() {
|
||||||
switch ev := obj.(type) {
|
switch ev := obj.(type) {
|
||||||
case core.NewMinedBlockEvent:
|
case core.ChainHeadEvent:
|
||||||
self.net.Broadcast("eth", NewBlockMsg, []interface{}{ev.Block, ev.Block.Td})
|
self.net.Broadcast("eth", NewBlockMsg, []interface{}{ev.Block, ev.Block.Td})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue