From 9ca49ea5e96e18d1d9d8a0cacde3b9db05ea0ec0 Mon Sep 17 00:00:00 2001
From: Benjamin Wenger <ben@elixxir.ioo>
Date: Wed, 23 Sep 2020 16:48:07 -0700
Subject: [PATCH] fixed historical rounds

---
 network/rounds/historical.go | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/network/rounds/historical.go b/network/rounds/historical.go
index 2031b86ac..65623f771 100644
--- a/network/rounds/historical.go
+++ b/network/rounds/historical.go
@@ -28,7 +28,8 @@ type historicalRoundsComms interface {
 // Waits to request many rounds at a time or for a timeout to trigger
 func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, quitCh <-chan struct{}) {
 
-	timer := make(chan time.Time)
+	timerCh := make(<-chan time.Time)
+	hasTimer := false
 
 	rng := m.Rng.GetStream()
 	var rounds []uint64
@@ -42,7 +43,8 @@ func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, quitCh <-c
 			rng.Close()
 			done = true
 		// if the timer elapses process rounds to ensure the delay isn't too long
-		case <-ticker.C:
+		case <-timerCh:
+			hasTimer = false
 			if len(rounds) > 0 {
 				shouldProcess = true
 			}
@@ -51,6 +53,8 @@ func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, quitCh <-c
 			rounds = append(rounds, uint64(rid))
 			if len(rounds) > int(m.params.MaxHistoricalRounds) {
 				shouldProcess = true
+			} else if !hasTimer {
+				timerCh = time.NewTimer(m.params.HistoricalRoundsPeriod).C
 			}
 		}
 		if !shouldProcess {
-- 
GitLab