optimize the judge of invalide notification.number (#22658)
Don't bother fetching genesis Co-authored-by: wuff1996 <33193253+wuff1996@users.noreply.github.com>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							31870a59ff
						
					
				
				
					commit
					410e731bea
				
			@@ -391,14 +391,15 @@ func (f *BlockFetcher) loop() {
 | 
				
			|||||||
				blockAnnounceDOSMeter.Mark(1)
 | 
									blockAnnounceDOSMeter.Mark(1)
 | 
				
			||||||
				break
 | 
									break
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if notification.number == 0 {
 | 
				
			||||||
 | 
									break
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			// If we have a valid block number, check that it's potentially useful
 | 
								// If we have a valid block number, check that it's potentially useful
 | 
				
			||||||
			if notification.number > 0 {
 | 
					 | 
				
			||||||
			if dist := int64(notification.number) - int64(f.chainHeight()); dist < -maxUncleDist || dist > maxQueueDist {
 | 
								if dist := int64(notification.number) - int64(f.chainHeight()); dist < -maxUncleDist || dist > maxQueueDist {
 | 
				
			||||||
				log.Debug("Peer discarded announcement", "peer", notification.origin, "number", notification.number, "hash", notification.hash, "distance", dist)
 | 
									log.Debug("Peer discarded announcement", "peer", notification.origin, "number", notification.number, "hash", notification.hash, "distance", dist)
 | 
				
			||||||
				blockAnnounceDropMeter.Mark(1)
 | 
									blockAnnounceDropMeter.Mark(1)
 | 
				
			||||||
				break
 | 
									break
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			// All is well, schedule the announce if block's not yet downloading
 | 
								// All is well, schedule the announce if block's not yet downloading
 | 
				
			||||||
			if _, ok := f.fetching[notification.hash]; ok {
 | 
								if _, ok := f.fetching[notification.hash]; ok {
 | 
				
			||||||
				break
 | 
									break
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user