From ebed1927bfb1e03bf92a83d5c1d10a6dad775885 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Mon, 9 May 2022 18:50:12 +0200 Subject: [PATCH] rpcclient: fix formatting --- rpcclient/infrastructure.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index 63874c1b4e..22430a2e1c 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -768,11 +768,14 @@ func (c *Client) handleSendPostMessage(jReq *jsonRequest) { } url := protocol + "://" + c.config.Host - var err error - var backoff time.Duration - var httpResponse *http.Response + var ( + err error + backoff time.Duration + httpResponse *http.Response + ) + tries := 10 - for i := 0; tries == 0 || i < tries; i++ { + for i := 0; i < tries; i++ { bodyReader := bytes.NewReader(jReq.marshalledJSON) httpReq, err := http.NewRequest("POST", url, bodyReader) if err != nil { @@ -799,7 +802,9 @@ func (c *Client) handleSendPostMessage(jReq *jsonRequest) { if backoff > time.Minute { backoff = time.Minute } - log.Debugf("Failed command [%s] with id %d attempt %d. Retrying in %v... \n", jReq.method, jReq.id, i, backoff) + log.Debugf("Failed command [%s] with id %d attempt %d."+ + " Retrying in %v... \n", jReq.method, jReq.id, + i, backoff) time.Sleep(backoff) continue }