diff --git a/exporter.go b/exporter.go index a1bdb42..54dcd32 100644 --- a/exporter.go +++ b/exporter.go @@ -518,7 +518,9 @@ func (e *Exporter) collectAccountTransactionsMetrics(wg *sync.WaitGroup, ch chan // add 1 second to the last update time to avoid querying the same activity twice minTime := account.Tx.LastUpdate.Add(time.Second * 1) - activities, err := heliumapi.GetActivityForAccount(account.Address, activityTypes, &minTime, nil) + // Explicitly set max_time, to avoid issues with server-side caching + maxTime := time.Now() + activities, err := heliumapi.GetActivityForAccount(account.Address, activityTypes, &minTime, &maxTime) if err != nil { log.Println(err) return diff --git a/heliumapi/accounts.go b/heliumapi/accounts.go index 15b8266..92caaad 100644 --- a/heliumapi/accounts.go +++ b/heliumapi/accounts.go @@ -37,10 +37,10 @@ func GetActivityForAccount(account string, filterTypes []string, minTime *time.T params["min_time"] = strings.Join(filterTypes, ",") } if minTime != nil { - params["min_time"] = minTime.UTC().Format(timeFormat) + params["min_time"] = minTime.UTC().Format(time.RFC3339) } if maxTime != nil { - params["max_time"] = maxTime.UTC().Format(timeFormat) + params["max_time"] = maxTime.UTC().Format(time.RFC3339) } // query the api @@ -88,10 +88,10 @@ func GetRewardTotalsForAccount(account string, minTime *time.Time, maxTime *time path := "/v1/accounts/" + account + "/rewards/sum" params := map[string]string{} if minTime != nil { - params["min_time"] = minTime.UTC().Format(timeFormat) + params["min_time"] = minTime.UTC().Format(time.RFC3339) } if maxTime != nil { - params["max_time"] = maxTime.UTC().Format(timeFormat) + params["max_time"] = maxTime.UTC().Format(time.RFC3339) } // query the api diff --git a/heliumapi/block.go b/heliumapi/block.go index c455452..51fa941 100644 --- a/heliumapi/block.go +++ b/heliumapi/block.go @@ -12,7 +12,7 @@ func GetHeight(maxTime *time.Time) (int, error) { path := "/v1/blocks/height" params := map[string]string{} if maxTime != nil { - params["max_time"] = maxTime.UTC().Format(timeFormat) + params["max_time"] = maxTime.UTC().Format(time.RFC3339) } // query the api diff --git a/heliumapi/hotspots.go b/heliumapi/hotspots.go index 99d66b8..1ef9342 100644 --- a/heliumapi/hotspots.go +++ b/heliumapi/hotspots.go @@ -31,10 +31,10 @@ func GetRewardsTotalForHotspot(hotspot string, minTime *time.Time, maxTime *time path := "/v1/hotspots/" + hotspot + "/rewards/sum" params := map[string]string{} if minTime != nil { - params["min_time"] = minTime.UTC().Format(timeFormat) + params["min_time"] = minTime.UTC().Format(time.RFC3339) } if maxTime != nil { - params["max_time"] = maxTime.UTC().Format(timeFormat) + params["max_time"] = maxTime.UTC().Format(time.RFC3339) } // query the api diff --git a/heliumapi/query.go b/heliumapi/query.go index 4f1772c..29506c3 100644 --- a/heliumapi/query.go +++ b/heliumapi/query.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "log" "net/http" - "strings" ) var ( diff --git a/heliumapi/types.go b/heliumapi/types.go index 2e48596..23bc054 100644 --- a/heliumapi/types.go +++ b/heliumapi/types.go @@ -1,12 +1,5 @@ package heliumapi -const ( - // WORKAROUND: for some reason, helium api partially breaks when given the timezone information - // in "max_time" and "min_time", even if the example code suggest that it supports it. - // For this reason, we cannot use time.RFC3339 as the time format. - timeFormat = "2006-01-02T15:04:05Z" -) - type AccountResp struct { Data Account `json:"data"` }