Skip to content

Commit c4979e5

Browse files
r1csholiman
authored andcommitted
optimize the judge of invalide notification.number
if notification.number is invalid, we chould break this select, the old logic will also continue.
1 parent 32150f8 commit c4979e5

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)