lint
This commit is contained in:
parent
36dd5d6331
commit
bfaf768d97
@ -16,9 +16,11 @@
|
||||
package beaconclient
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -71,14 +73,17 @@ func (bc BeaconClient) QueryHeadSync() (Sync, error) {
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
var body bytes.Buffer
|
||||
buf := bufio.NewWriter(&body)
|
||||
_, err = io.Copy(buf, resp.Body)
|
||||
|
||||
if err != nil {
|
||||
return syncStatus, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(body, &syncStatus); err != nil {
|
||||
if err := json.Unmarshal(body.Bytes(), &syncStatus); err != nil {
|
||||
loghelper.LogEndpoint(bcSync).WithFields(log.Fields{
|
||||
"rawMessage": string(body),
|
||||
"rawMessage": body.String(),
|
||||
"err": err,
|
||||
}).Error("Unable to unmarshal sync status")
|
||||
return syncStatus, err
|
||||
@ -149,14 +154,16 @@ func (bc BeaconClient) queryLighthouseDbInfo() (LighthouseDatabaseInfo, error) {
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
var body bytes.Buffer
|
||||
buf := bufio.NewWriter(&body)
|
||||
_, err = io.Copy(buf, resp.Body)
|
||||
if err != nil {
|
||||
return dbInfo, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(body, &dbInfo); err != nil {
|
||||
if err := json.Unmarshal(body.Bytes(), &dbInfo); err != nil {
|
||||
loghelper.LogEndpoint(lhDbInfo).WithFields(log.Fields{
|
||||
"rawMessage": string(body),
|
||||
"rawMessage": body.String(),
|
||||
"err": err,
|
||||
}).Error("Unable to unmarshal the lighthouse database information")
|
||||
return dbInfo, err
|
||||
|
@ -18,8 +18,10 @@
|
||||
package beaconclient
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -59,11 +61,13 @@ func querySsz(endpoint string, slot Slot) ([]byte, int, error) {
|
||||
return nil, rc, fmt.Errorf("HTTP Error: %d", rc)
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(response.Body)
|
||||
var body bytes.Buffer
|
||||
buf := bufio.NewWriter(&body)
|
||||
_, err = io.Copy(buf, response.Body)
|
||||
if err != nil {
|
||||
loghelper.LogSlotError(slot.Number(), err).Error("Unable to turn response into a []bytes array!")
|
||||
return nil, rc, fmt.Errorf("Unable to turn response into a []bytes array!: %s", err.Error())
|
||||
}
|
||||
|
||||
return body, rc, nil
|
||||
return body.Bytes(), rc, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user