diff options
author | Miya Chen <miyatlchen@gmail.com> | 2017-08-18 18:58:36 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-08-18 18:58:36 +0800 |
commit | bf1e2631281e1e439533f2abcf1e99a7b2f9552a (patch) | |
tree | a8b86720edf085a6531e7042ef33f36a993540d5 /les/server.go | |
parent | a4da8416eec6a00c358b6a612d21e7cdf859d588 (diff) | |
download | go-tangerine-bf1e2631281e1e439533f2abcf1e99a7b2f9552a.tar go-tangerine-bf1e2631281e1e439533f2abcf1e99a7b2f9552a.tar.gz go-tangerine-bf1e2631281e1e439533f2abcf1e99a7b2f9552a.tar.bz2 go-tangerine-bf1e2631281e1e439533f2abcf1e99a7b2f9552a.tar.lz go-tangerine-bf1e2631281e1e439533f2abcf1e99a7b2f9552a.tar.xz go-tangerine-bf1e2631281e1e439533f2abcf1e99a7b2f9552a.tar.zst go-tangerine-bf1e2631281e1e439533f2abcf1e99a7b2f9552a.zip |
core, light: send chain events using event.Feed (#14865)
Diffstat (limited to 'les/server.go')
-rw-r--r-- | les/server.go | 9 |
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 } |