From c8ce2aa2d22428edb287e4a68977a031edcc4327 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 20 Aug 2018 14:28:10 +0200 Subject: [PATCH] discovery/gossiper: reaturn early of no premature to process --- discovery/gossiper.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index ce602cae1..6ac1d570c 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1139,12 +1139,15 @@ func (d *AuthenticatedGossiper) networkHandler() { d.Lock() numPremature := len(d.prematureAnnouncements[uint32(newBlock.Height)]) d.Unlock() - if numPremature != 0 { - log.Infof("Re-processing %v premature "+ - "announcements for height %v", - numPremature, blockHeight) + + // Return early if no announcement to process. + if numPremature == 0 { + continue } + log.Infof("Re-processing %v premature announcements "+ + "for height %v", numPremature, blockHeight) + d.Lock() for _, ann := range d.prematureAnnouncements[uint32(newBlock.Height)] { emittedAnnouncements := d.processNetworkAnnouncement(ann)