1
0
Fork 0
This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
helium-blockchain-exporter/heliumapi/stats.go

26 lines
482 B
Go
Raw Normal View History

2021-09-13 03:25:47 +00:00
package heliumapi
import (
"encoding/json"
"fmt"
)
func GetBlockchainStats() (*BlockchainStats, error) {
2021-09-13 03:25:47 +00:00
const path = "/v1/stats"
// query the api
respBody, err := getHeliumApi(path, nil)
if err != nil {
return nil, err
}
// unmarshal the response
respobject := BlockchainStatsResp{}
2021-09-13 03:25:47 +00:00
err = json.Unmarshal(respBody, &respobject)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal response from path %v: %v", path, err)
}
return &respobject.Data, nil
2021-09-13 03:25:47 +00:00
}