Skip to content

Commit 018a11a

Browse files
r1csjagdeep sidhu
authored andcommitted
optimize the judge of invalide notification.number (ethereum#22658)
Don't bother fetching genesis Co-authored-by: wuff1996 <33193253+wuff1996@users.noreply.github.com>
1 parent c86904d commit 018a11a

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
@@ -396,13 +396,14 @@ func (f *BlockFetcher) loop() {
396396
blockAnnounceDOSMeter.Mark(1)
397397
break
398398
}
399+
if notification.number == 0 {
400+
break
401+
}
399402
// If we have a valid block number, check that it's potentially useful
400-
if notification.number > 0 {
401-
if dist := int64(notification.number) - int64(f.chainHeight()); dist < -maxUncleDist || dist > maxQueueDist {
402-
log.Debug("Peer discarded announcement", "peer", notification.origin, "number", notification.number, "hash", notification.hash, "distance", dist)
403-
blockAnnounceDropMeter.Mark(1)
404-
break
405-
}
403+
if dist := int64(notification.number) - int64(f.chainHeight()); dist < -maxUncleDist || dist > maxQueueDist {
404+
log.Debug("Peer discarded announcement", "peer", notification.origin, "number", notification.number, "hash", notification.hash, "distance", dist)
405+
blockAnnounceDropMeter.Mark(1)
406+
break
406407
}
407408
// All is well, schedule the announce if block's not yet downloading
408409
if _, ok := f.fetching[notification.hash]; ok {

0 commit comments

Comments
 (0)