From f0cd642c2d5ab2933c9c7297b7b192c55246a81c Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Wed, 17 Jun 2020 20:35:28 -0400 Subject: [PATCH] move cache check out of loop --- snow/engine/avalanche/bootstrapper.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/snow/engine/avalanche/bootstrapper.go b/snow/engine/avalanche/bootstrapper.go index 43d2b47..3958fe7 100644 --- a/snow/engine/avalanche/bootstrapper.go +++ b/snow/engine/avalanche/bootstrapper.go @@ -125,13 +125,11 @@ func (b *bootstrapper) fetch(vtxID ids.ID) error { // Process vertices func (b *bootstrapper) process(vtx avalanche.Vertex) error { toProcess := newMaxVertexHeap() - toProcess.Push(vtx) + if _, ok := b.processedCache.Get(vtx.ID()); !ok { // only process if we haven't already + toProcess.Push(vtx) + } for toProcess.Len() > 0 { vtx := toProcess.Pop() - if _, ok := b.processedCache.Get(vtx.ID()); ok { // already processed this - continue - } - switch vtx.Status() { case choices.Unknown: if err := b.fetch(vtx.ID()); err != nil {