mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
les: remove delayed announcement
This commit is contained in:
parent
4a6959a839
commit
36bfbc620e
2 changed files with 3 additions and 11 deletions
|
|
@ -242,7 +242,7 @@ func (f *lightFetcher) unregisterPeer(p *peer) {
|
||||||
|
|
||||||
// announce processes a new announcement message received from a peer, adding new
|
// 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
|
// 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()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
p.Log().Debug("Received new announcement", "number", head.Number, "hash", head.Hash, "reorg", head.ReorgDepth)
|
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 fp.lastAnnounced != nil && head.Td.Cmp(fp.lastAnnounced.td) <= 0 {
|
||||||
if acceptNonMonotonic {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// announced tds should be strictly monotonic
|
// announced tds should be strictly monotonic
|
||||||
p.Log().Debug("Received non-monotonic td", "current", head.Td, "previous", fp.lastAnnounced.td)
|
p.Log().Debug("Received non-monotonic td", "current", head.Td, "previous", fp.lastAnnounced.td)
|
||||||
go f.pm.removePeer(p.id)
|
go f.pm.removePeer(p.id)
|
||||||
|
|
|
||||||
|
|
@ -318,12 +318,7 @@ func (pm *ProtocolManager) handle(p *peer) error {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
head := p.headInfo
|
head := p.headInfo
|
||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
if pm.fetcher != nil {
|
pm.fetcher.announce(p, head)
|
||||||
go func() {
|
|
||||||
time.Sleep(time.Second * 2)
|
|
||||||
pm.fetcher.announce(p, head, true)
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.poolEntry != nil {
|
if p.poolEntry != nil {
|
||||||
pm.serverPool.registered(p.poolEntry)
|
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)
|
p.Log().Trace("Announce message content", "number", req.Number, "hash", req.Hash, "td", req.Td, "reorg", req.ReorgDepth)
|
||||||
if pm.fetcher != nil {
|
if pm.fetcher != nil {
|
||||||
pm.fetcher.announce(p, &req, false)
|
pm.fetcher.announce(p, &req)
|
||||||
}
|
}
|
||||||
|
|
||||||
case GetBlockHeadersMsg:
|
case GetBlockHeadersMsg:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue