From 93260fb1a40c468ef635016445f09928f4a960a8 Mon Sep 17 00:00:00 2001
From: Jake Taylor <jake@elixxir.io>
Date: Wed, 12 Jan 2022 16:43:48 -0600
Subject: [PATCH] fix node registration buffer being filled with redundant
 calls

---
 interfaces/params/network.go | 2 +-
 network/gateway/hostPool.go  | 6 +++---
 network/gateway/sender.go    | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/interfaces/params/network.go b/interfaces/params/network.go
index d6f9ef1b0..67d083802 100644
--- a/interfaces/params/network.go
+++ b/interfaces/params/network.go
@@ -46,7 +46,7 @@ func GetDefaultNetwork() Network {
 	n := Network{
 		TrackNetworkPeriod:        100 * time.Millisecond,
 		MaxCheckedRounds:          500,
-		RegNodesBufferLen:         500,
+		RegNodesBufferLen:         1000,
 		NetworkHealthTimeout:      30 * time.Second,
 		E2EParams:                 GetDefaultE2ESessionParams(),
 		ParallelNodeRegistrations: 20,
diff --git a/network/gateway/hostPool.go b/network/gateway/hostPool.go
index 5bb0b8204..43ae1481b 100644
--- a/network/gateway/hostPool.go
+++ b/network/gateway/hostPool.go
@@ -578,7 +578,7 @@ func (h *HostPool) updateConns() error {
 		return errors.Errorf("Unable to convert new NDF to set: %+v", err)
 	}
 
-	// Filter out gateway IDs
+	// Filter out unwanted gateway IDs
 	newMap = h.getFilter()(newMap, h.ndf)
 
 	// Keep track of the old NDF set
@@ -588,7 +588,7 @@ func (h *HostPool) updateConns() error {
 
 	// Handle adding Gateways
 	for gwId, ndfIdx := range newMap {
-		if _, ok := oldMap[gwId]; !ok {
+		if _, ok := oldMap[gwId]; !ok && gwId.GetType() == id.Gateway {
 			// If GwId in newMap is not in ndfMap, add the Gateway
 			h.addGateway(gwId.DeepCopy(), ndfIdx)
 		}
@@ -596,7 +596,7 @@ func (h *HostPool) updateConns() error {
 
 	// Handle removing Gateways
 	for gwId := range oldMap {
-		if _, ok := newMap[gwId]; !ok {
+		if _, ok := newMap[gwId]; !ok && gwId.GetType() == id.Gateway {
 			// If GwId in ndfMap is not in newMap, remove the Gateway
 			h.removeGateway(gwId.DeepCopy())
 		}
diff --git a/network/gateway/sender.go b/network/gateway/sender.go
index d09decce4..b3b029f36 100644
--- a/network/gateway/sender.go
+++ b/network/gateway/sender.go
@@ -153,7 +153,7 @@ func (s *Sender) SendToPreferred(targets []*id.ID, sendFunc sendToPreferredFunc,
 		for targetIdx := range proxies {
 			// Return an error if the timeout duration is reached
 			if netTime.Since(startTime) > timeout {
-				return nil, errors.Errorf("iterating over target's procies "+
+				return nil, errors.Errorf("iterating over target's proxies "+
 					"timed out after %s", timeout)
 			}
 
-- 
GitLab