aboutsummaryrefslogtreecommitdiffstats
path: root/les/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'les/server.go')
-rw-r--r--les/server.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/les/server.go b/les/server.go
index 39ef0efff..8b2730714 100644
--- a/les/server.go
+++ b/les/server.go
@@ -271,7 +271,8 @@ func (s *requestCostStats) update(msgCode, reqCnt, cost uint64) {
func (pm *ProtocolManager) blockLoop() {
pm.wg.Add(1)
- sub := pm.eventMux.Subscribe(core.ChainHeadEvent{})
+ headCh := make(chan core.ChainHeadEvent, 10)
+ headSub := pm.blockchain.SubscribeChainHeadEvent(headCh)
newCht := make(chan struct{}, 10)
newCht <- struct{}{}
go func() {
@@ -280,10 +281,10 @@ func (pm *ProtocolManager) blockLoop() {
lastBroadcastTd := common.Big0
for {
select {
- case ev := <-sub.Chan():
+ case ev := <-headCh:
peers := pm.peers.AllPeers()
if len(peers) > 0 {
- header := ev.Data.(core.ChainHeadEvent).Block.Header()
+ header := ev.Block.Header()
hash := header.Hash()
number := header.Number.Uint64()
td := core.GetTd(pm.chainDb, hash, number)
@@ -319,7 +320,7 @@ func (pm *ProtocolManager) blockLoop() {
}
}()
case <-pm.quitSync:
- sub.Unsubscribe()
+ headSub.Unsubscribe()
pm.wg.Done()
return
}