From ffd9816f23667f5f3aa1c2a0fcb7094a63ccb1b6 Mon Sep 17 00:00:00 2001
From: Benjamin Wenger <ben@elixxir.ioo>
Date: Wed, 6 Oct 2021 16:20:07 -0700
Subject: [PATCH] made the host pool limit the number of contacted nodes if the
 total number of avalbile nodes is less than the number to be initally
 contacted

---
 network/gateway/hostPool.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/network/gateway/hostPool.go b/network/gateway/hostPool.go
index c8b81f169..09bb8a840 100644
--- a/network/gateway/hostPool.go
+++ b/network/gateway/hostPool.go
@@ -205,6 +205,9 @@ func (h *HostPool) initialize(startIdx uint32) error {
 	}
 	numGatewaysToTry := h.poolParams.MaxPings
 	numGateways := uint32(len(randomGateways))
+	if numGatewaysToTry>numGateways{
+		numGatewaysToTry = numGateways
+	}
 	resultList := make([]gatewayDuration, 0, numGatewaysToTry)
 
 	// Begin trying gateways
-- 
GitLab