From 36bfbc620e599e68e7bd3caba009803d26d41029 Mon Sep 17 00:00:00 2001 From: Zsolt Felfoldi Date: Tue, 14 Aug 2018 14:01:07 +0200 Subject: [PATCH] les: remove delayed announcement --- les/fetcher.go | 5 +---- les/handler.go | 9 ++------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/les/fetcher.go b/les/fetcher.go index 67685145c0..cc539c42bf 100644 --- a/les/fetcher.go +++ b/les/fetcher.go @@ -242,7 +242,7 @@ func (f *lightFetcher) unregisterPeer(p *peer) { // announce processes a new announcement message received from a peer, adding new // nodes to the peer's block tree and removing old nodes if necessary -func (f *lightFetcher) announce(p *peer, head *announceData, acceptNonMonotonic bool) { +func (f *lightFetcher) announce(p *peer, head *announceData) { f.lock.Lock() defer f.lock.Unlock() p.Log().Debug("Received new announcement", "number", head.Number, "hash", head.Hash, "reorg", head.ReorgDepth) @@ -254,9 +254,6 @@ func (f *lightFetcher) announce(p *peer, head *announceData, acceptNonMonotonic } if fp.lastAnnounced != nil && head.Td.Cmp(fp.lastAnnounced.td) <= 0 { - if acceptNonMonotonic { - return - } // announced tds should be strictly monotonic p.Log().Debug("Received non-monotonic td", "current", head.Td, "previous", fp.lastAnnounced.td) go f.pm.removePeer(p.id) diff --git a/les/handler.go b/les/handler.go index babc1d62fe..fe9209dc94 100644 --- a/les/handler.go +++ b/les/handler.go @@ -318,12 +318,7 @@ func (pm *ProtocolManager) handle(p *peer) error { p.lock.Lock() head := p.headInfo p.lock.Unlock() - if pm.fetcher != nil { - go func() { - time.Sleep(time.Second * 2) - pm.fetcher.announce(p, head, true) - }() - } + pm.fetcher.announce(p, head) if p.poolEntry != nil { pm.serverPool.registered(p.poolEntry) @@ -419,7 +414,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { p.Log().Trace("Announce message content", "number", req.Number, "hash", req.Hash, "td", req.Td, "reorg", req.ReorgDepth) if pm.fetcher != nil { - pm.fetcher.announce(p, &req, false) + pm.fetcher.announce(p, &req) } case GetBlockHeadersMsg: