auctioneer: make initial backoff use more clear
When normally connecting for the first time, the initial backoff is set
to 0 and no wait is executed. We make this a bit more clear by moving
the zero check into the loop and out of the `wait` method.
@@ -746,15 +746,14 @@ func (c *Client) SendAuctionMessage(msg *poolrpc.ClientAuctionMessage) error {
// wait blocks for a given amount of time but returns immediately if the client
// is shutting down.
func (c *Client) wait(backoff time.Duration) error {
- if backoff > 0 {
select {
case <-time.After(backoff):
+ return nil
+
case <-c.quit:
return ErrClientShutdown
}
}
- return nil
-}
// connectServerStream opens the initial connection to the server for the stream
// of account updates and handles reconnect trials with incremental backoff.
@@ -769,10 +768,12 @@ func (c *Client) connectServerStream(initialBackoff time.Duration,
)
for i := 0; i < numRetries; i++ {
// Wait before connecting in case this is a reconnect trial.
+ if backoff != 0 {
err = c.wait(backoff)
if err != nil {
return err
}
+ }
// Try connecting by querying a "cheap" RPC that the server can
// answer from memory only.
