From 8e6d44bccf2df61912bfdfc6376eca1b623b9bfe Mon Sep 17 00:00:00 2001
From: josh <josh@elixxir.io>
Date: Wed, 15 Dec 2021 14:57:24 -0800
Subject: [PATCH] Track rate limiting param changes in network follower

---
 network/follow.go | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/network/follow.go b/network/follow.go
index 50f98f0ac..e25f5ff6c 100644
--- a/network/follow.go
+++ b/network/follow.go
@@ -194,6 +194,28 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
 		m.Session.SetNDF(m.GetInstance().GetPartialNdf().Get())
 	}
 
+	// Pull rate limiting parameter values from NDF
+	ndfRateLimitParam := m.Instance.GetPartialNdf().Get().RateLimits
+	ndfCapacity, ndfLeakedTokens, ndfLeakDuration := uint32(ndfRateLimitParam.Capacity),
+		uint32(ndfRateLimitParam.LeakedTokens), time.Duration(ndfRateLimitParam.LeakDuration)
+
+	// Pull internal rate limiting parameters from RAM
+	internalRateLimitParams := m.Internal.Session.GetBucketParams().Get()
+
+	// If any param value in our internal store does not
+	// match the NDF's corresponding value, update our internal store
+	if ndfCapacity != internalRateLimitParams.Capacity ||
+		ndfLeakedTokens != internalRateLimitParams.LeakedTokens ||
+		ndfLeakDuration != internalRateLimitParams.LeakDuration {
+		// Update internally stored params
+		err = m.Internal.Session.GetBucketParams().
+			UpdateParams(ndfCapacity, ndfLeakedTokens, ndfLeakDuration)
+		if err != nil {
+			jww.ERROR.Printf("%+v", err)
+			return
+		}
+	}
+
 	// Update the address space size
 	// todo: this is a fix for incompatibility with the live network
 	// remove once the live network has been pushed to
-- 
GitLab