From ac0564dc1453cd9eec5a8fb62c6628de5922863c Mon Sep 17 00:00:00 2001
From: benjamin <ben@elixxir.io>
Date: Tue, 25 Oct 2022 13:04:38 -0700
Subject: [PATCH] improved code quality on the selection of the identtiy range

---
 cmix/identity/tracker.go | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/cmix/identity/tracker.go b/cmix/identity/tracker.go
index 9de1fd3d9..a292711b7 100644
--- a/cmix/identity/tracker.go
+++ b/cmix/identity/tracker.go
@@ -47,6 +47,11 @@ const (
 	// NetworkRetention is how long messages are
 	// retained on the network
 	NetworkRetention = 500 * time.Hour
+
+	// GenerationDelta is how far into the past
+	// to go in order to ensure all relevant
+	// ephemeral identities are generated
+	GenerationDelta = time.Duration(ephemeral.Period) + (5 * time.Second)
 )
 
 type Tracker interface {
@@ -133,7 +138,7 @@ func (t *manager) StartProcesses() stoppable.Stoppable {
 
 // AddIdentity adds an identity to be tracked.
 func (t *manager) AddIdentity(id *id.ID, validUntil time.Time, persistent bool) {
-	lastGeneration := netTime.Now().Add(-time.Duration(ephemeral.Period))
+	lastGeneration := netTime.Now().Add(-GenerationDelta)
 	t.newIdentity <- TrackedID{
 		NextGeneration: netTime.Now().Add(-time.Second),
 		LastGeneration: lastGeneration,
@@ -152,8 +157,8 @@ func (t *manager) AddIdentityWithHistory(id *id.ID, validUntil, historicalBeginn
 	}
 
 	if now := time.Now(); historicalBeginning.After(now) ||
-		now.Sub(historicalBeginning) < time.Duration(ephemeral.Period) {
-		historicalBeginning = now.Add(-time.Duration(ephemeral.Period))
+		now.Sub(historicalBeginning) < GenerationDelta {
+		historicalBeginning = now.Add(-GenerationDelta)
 	}
 
 	t.newIdentity <- TrackedID{
-- 
GitLab