From b3bee0a7420af336d36d818c7707852d90db2e4f Mon Sep 17 00:00:00 2001 From: Jake Taylor <jake@elixxir.io> Date: Wed, 29 Dec 2021 13:55:21 -0600 Subject: [PATCH] fix getroundinfo timeout --- api/results.go | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/api/results.go b/api/results.go index 7d4b2555f..f2358f366 100644 --- a/api/results.go +++ b/api/results.go @@ -93,17 +93,18 @@ func (c *Client) getRoundResults(roundList []id.Round, timeout time.Duration, oldestRound := networkInstance.GetOldestRoundID() + roundEventTimeout := 7 * time.Second + if timeout < roundEventTimeout { + roundEventTimeout = timeout + } + // Parse and adjudicate every round for _, rnd := range roundList { // Every round is timed out by default, until proven to have finished roundsResults[rnd] = TimeOut roundInfo, err := networkInstance.GetRound(rnd) - if err != nil && rnd < oldestRound { - // If round is older that oldest round in our buffer - // Add it to the historical round request (performed later) - historicalRequest.Rounds = append(historicalRequest.Rounds, uint64(rnd)) - numResults++ - } else { + // If we have the round in the buffer + if err == nil { // Check if the round is done (completed or failed) or in progress if states.Round(roundInfo.State) == states.COMPLETED { roundsResults[rnd] = Succeeded @@ -113,7 +114,20 @@ func (c *Client) getRoundResults(roundList []id.Round, timeout time.Duration, } else { // If in progress, add a channel monitoring its state roundEvents.AddRoundEventChan(rnd, sendResults, - timeout/2, states.COMPLETED, states.FAILED) + roundEventTimeout, states.COMPLETED, states.FAILED) + numResults++ + } + } else { + // Update the oldest round (buffer may have updated externally) + if rnd < oldestRound { + // If round is older that oldest round in our buffer + // Add it to the historical round request (performed later) + historicalRequest.Rounds = append(historicalRequest.Rounds, uint64(rnd)) + numResults++ + } else { + // Otherwise, monitor its progress + roundEvents.AddRoundEventChan(rnd, sendResults, + roundEventTimeout, states.COMPLETED, states.FAILED) numResults++ } } -- GitLab