Skip to content
Snippets Groups Projects
Commit b3bee0a7 authored by Jake Taylor's avatar Jake Taylor
Browse files

fix getroundinfo timeout

parent 076d88f1
No related branches found
No related tags found
2 merge requests!117Release,!106fix getroundinfo timeout
......@@ -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++
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment