move cache check out of loop

This commit is contained in:
Dan Laine 2020-06-17 20:35:28 -04:00
parent f4a789b433
commit f0cd642c2d
1 changed files with 3 additions and 5 deletions

View File

@ -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 {