Skip to content

Commit 410e731

Browse files
authored
optimize the judge of invalide notification.number (#22658)
Don't bother fetching genesis Co-authored-by: wuff1996 <[email protected]>
1 parent 31870a5 commit 410e731

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

eth/fetcher/block_fetcher.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,14 @@ func (f *BlockFetcher) loop() {
391391
blockAnnounceDOSMeter.Mark(1)
392392
break
393393
}
394+
if notification.number == 0 {
395+
break
396+
}
394397
// If we have a valid block number, check that it's potentially useful
395-
if notification.number > 0 {
396-
if dist := int64(notification.number) - int64(f.chainHeight()); dist < -maxUncleDist || dist > maxQueueDist {
397-
log.Debug("Peer discarded announcement", "peer", notification.origin, "number", notification.number, "hash", notification.hash, "distance", dist)
398-
blockAnnounceDropMeter.Mark(1)
399-
break
400-
}
398+
if dist := int64(notification.number) - int64(f.chainHeight()); dist < -maxUncleDist || dist > maxQueueDist {
399+
log.Debug("Peer discarded announcement", "peer", notification.origin, "number", notification.number, "hash", notification.hash, "distance", dist)
400+
blockAnnounceDropMeter.Mark(1)
401+
break
401402
}
402403
// All is well, schedule the announce if block's not yet downloading
403404
if _, ok := f.fetching[notification.hash]; ok {

0 commit comments

Comments
 (0)