From 1995f755fcf72082560d46b7d666591db94d3141 Mon Sep 17 00:00:00 2001
From: Jake Taylor <jake@elixxir.io>
Date: Wed, 5 Jan 2022 11:48:27 -0600
Subject: [PATCH] attempt to fix GetRoundResults

---
 api/results.go | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/api/results.go b/api/results.go
index 4a31b66b5..19424dd54 100644
--- a/api/results.go
+++ b/api/results.go
@@ -158,12 +158,9 @@ func (c *Client) getRoundResults(roundList []id.Round, timeout time.Duration,
 				roundCallback(false, true, roundsResults)
 				return
 			case roundReport := <-sendResults:
-				// Skip if the round is nil (unknown from historical rounds)
-				// they default to timed out, so correct behavior is preserved
-				if roundReport.RoundInfo == nil {
-					allRoundsSucceeded = false
-					numResults--
-				} else if roundReport.TimedOut {
+				// Skip if the round is timed out, meaning unknown from historical rounds
+				// or timed out on RoundEvents channel
+				if roundReport.TimedOut {
 					// Generate a message to track the timed out round
 					timeoutRequest := &pb.HistoricalRounds{
 						Rounds: []uint64{roundReport.RoundInfo.ID},
@@ -219,9 +216,17 @@ func (c *Client) getHistoricalRounds(msg *pb.HistoricalRounds,
 	}
 
 	// Service historical rounds, sending back to the caller thread
-	for _, ri := range resp.Rounds {
-		sendResults <- ds.EventReturn{
-			RoundInfo: ri,
+	for i, ri := range resp.Rounds {
+		if ri == nil {
+			// Handle unknown by historical rounds
+			sendResults <- ds.EventReturn{
+				RoundInfo: &pb.RoundInfo{ID: msg.Rounds[i]},
+				TimedOut:  true,
+			}
+		} else {
+			sendResults <- ds.EventReturn{
+				RoundInfo: ri,
+			}
 		}
 	}
 }
-- 
GitLab