diff --git a/api/results.go b/api/results.go index 20d4871c5fa6610bfe379c81a6e006281e46d396..24d22badd161f5e01174bc8daf7374fb42f58608 100644 --- a/api/results.go +++ b/api/results.go @@ -113,14 +113,14 @@ func (c *Client) getRoundResults(roundList []id.Round, timeout time.Duration, numResults++ } } else { - // Update oldest round (buffer may have updated externally) + // 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 it's progress + // Otherwise, monitor its progress roundEvents.AddRoundEventChan(rnd, sendResults, timeout-time.Millisecond, states.COMPLETED, states.FAILED) numResults++ @@ -151,13 +151,19 @@ func (c *Client) getRoundResults(roundList []id.Round, timeout time.Duration, roundCallback(false, true, roundsResults) return case roundReport := <-sendResults: - - numResults-- - // Skip if the round is nil (unknown from historical rounds) // they default to timed out, so correct behavior is preserved - if roundReport.RoundInfo == nil || roundReport.TimedOut { + if roundReport.RoundInfo == nil { allRoundsSucceeded = false + numResults-- + } else if roundReport.TimedOut { + // Generate a message to track the timed out round + timeoutRequest := &pb.HistoricalRounds{ + Rounds: []uint64{roundReport.RoundInfo.ID}, + } + // Request that round's information, feeding back into sendResults + jww.DEBUG.Printf("Sending HistoricalRounds retry for Round %d", roundReport.RoundInfo.ID) + go c.getHistoricalRounds(timeoutRequest, sendResults, commsInterface) } else { // If available, denote the result roundId := id.Round(roundReport.RoundInfo.ID) @@ -167,6 +173,7 @@ func (c *Client) getRoundResults(roundList []id.Round, timeout time.Duration, roundsResults[roundId] = Failed allRoundsSucceeded = false } + numResults-- } } } @@ -176,7 +183,7 @@ func (c *Client) getRoundResults(roundList []id.Round, timeout time.Duration, } // Helper function which asynchronously pings a random gateway until -// it gets information on it's requested historical rounds +// it gets information on its requested historical rounds func (c *Client) getHistoricalRounds(msg *pb.HistoricalRounds, sendResults chan ds.EventReturn, comms historicalRoundsComm) {