From 7cdb43b395212758f825185c4cd25d0a5b0b3efa Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Fri, 24 Dec 2021 16:03:32 -0500 Subject: [PATCH] formatting --- heliumapi/accounts.go | 12 ++++-------- heliumapi/block.go | 3 +-- heliumapi/hotspots.go | 12 ++++-------- heliumapi/oracleprices.go | 3 +-- heliumapi/query.go | 9 +++------ heliumapi/stats.go | 3 +-- 6 files changed, 14 insertions(+), 28 deletions(-) diff --git a/heliumapi/accounts.go b/heliumapi/accounts.go index 95cd7c4..31a9503 100644 --- a/heliumapi/accounts.go +++ b/heliumapi/accounts.go @@ -21,8 +21,7 @@ func GetAccountForAddress(account string) (*Account, error) { // unmarshal the response respobject := AccountResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } @@ -53,8 +52,7 @@ func GetActivityForAccount(account string, filterTypes []string, minTime *time.T combinedResp := activity.ActivityResp{} for _, respBody := range resBodies { activityResp := activity.ActivityResp{} - err = json.Unmarshal(respBody, &activityResp) - if err != nil { + if err := json.Unmarshal(respBody, &activityResp); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } combinedResp.Data = append(combinedResp.Data, activityResp.Data...) @@ -75,8 +73,7 @@ func GetActivityCountsForAccount(account string) (*ActivityCounts, error) { // unmarshal the response respobject := ActivityCountsResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } @@ -95,8 +92,7 @@ func GetHotspotsForAccount(account string) ([]Hotspot, error) { // unmarshal the response respobject := AccountHotspotsResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } diff --git a/heliumapi/block.go b/heliumapi/block.go index 51fa941..683c749 100644 --- a/heliumapi/block.go +++ b/heliumapi/block.go @@ -23,8 +23,7 @@ func GetHeight(maxTime *time.Time) (int, error) { // unmarshal the response respobject := HeightResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return -1, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } diff --git a/heliumapi/hotspots.go b/heliumapi/hotspots.go index 71db9b2..9f56d22 100644 --- a/heliumapi/hotspots.go +++ b/heliumapi/hotspots.go @@ -33,8 +33,7 @@ func GetHotspotActivity(hotspot string, filterTypes []string, minTime *time.Time combinedResp := activity.ActivityResp{} for _, respBody := range resBodies { activityResp := activity.ActivityResp{} - err = json.Unmarshal(respBody, &activityResp) - if err != nil { + if err := json.Unmarshal(respBody, &activityResp); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } combinedResp.Data = append(combinedResp.Data, activityResp.Data...) @@ -55,8 +54,7 @@ func GetHotspotActivityCounts(hotspot string) (*ActivityCounts, error) { // unmarshal the response respobject := ActivityCountsResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } @@ -75,8 +73,7 @@ func GetWitnessesForHotspot(hotspot string) ([]Hotspot, error) { // unmarshal the response respobject := WitnessesResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } @@ -95,8 +92,7 @@ func GetWitnessedForHotspot(hotspot string) ([]Hotspot, error) { // unmarshal the response respobject := WitnessedResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } diff --git a/heliumapi/oracleprices.go b/heliumapi/oracleprices.go index e59c848..e249a2c 100644 --- a/heliumapi/oracleprices.go +++ b/heliumapi/oracleprices.go @@ -17,8 +17,7 @@ func GetCurrentOraclePrice() (*CurrentOraclePrice, error) { // unmarshal the response respobject := CurrentOraclePriceResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } diff --git a/heliumapi/query.go b/heliumapi/query.go index 42f6f08..835f7bd 100644 --- a/heliumapi/query.go +++ b/heliumapi/query.go @@ -53,8 +53,7 @@ func getHeliumApi(path string, params *map[string]string) ([]byte, error) { } // ensure we respect the rate limit - err := Limiter.Wait(context.Background()) - if err != nil { + if err := Limiter.Wait(context.Background()); err != nil { return nil, err } @@ -111,8 +110,7 @@ func getHeliumApiWithCursor(path string, params *map[string]string) ([][]byte, e for { // ensure we respect the rate limit - err := Limiter.Wait(context.Background()) - if err != nil { + if err := Limiter.Wait(context.Background()); err != nil { return nil, err } @@ -138,8 +136,7 @@ func getHeliumApiWithCursor(path string, params *map[string]string) ([][]byte, e // parse the response body for a cursor respCursor.Cursor = "" - err = json.Unmarshal(body, &respCursor) - if err != nil { + if err := json.Unmarshal(body, &respCursor); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", req.URL.String(), err) } diff --git a/heliumapi/stats.go b/heliumapi/stats.go index 417a8c0..13c779d 100644 --- a/heliumapi/stats.go +++ b/heliumapi/stats.go @@ -17,8 +17,7 @@ func GetBlockchainStats() (*BlockchainStats, error) { // unmarshal the response respobject := BlockchainStatsResp{} - err = json.Unmarshal(respBody, &respobject) - if err != nil { + if err := json.Unmarshal(respBody, &respobject); err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) }