Skip to content

Commit 9b1c9fa

Browse files
committed
v0.3.1
1 parent f18efca commit 9b1c9fa

File tree

10 files changed

+8
-62
lines changed

10 files changed

+8
-62
lines changed

config/config.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ package config
22

33
import (
44
"log"
5-
// "time"
65

76
"github.com/BurntSushi/toml"
87
rpc "github.com/node-a-team/terra-validator_exporter/getData/rpc"
98
rest "github.com/node-a-team/terra-validator_exporter/getData/rest"
10-
// "github.com/spf13/viper"
119
)
1210

1311
const (
@@ -40,7 +38,7 @@ type configType struct {
4038
}
4139

4240

43-
func Init() {
41+
func Init() string {
4442

4543
Config = readConfig()
4644

@@ -49,15 +47,13 @@ func Init() {
4947

5048
rest.OperAddr = Config.Validator.OperatorAddr
5149

50+
return Config.Options.ListenPort
5251
}
5352

5453
func readConfig() configType {
5554

5655
var config configType
5756

58-
// path := viper.GetString(ConfigPath)+"/config.toml"
59-
60-
// if _, err := toml.DecodeFile(path, &config); err != nil{
6157
if _, err := toml.DecodeFile(ConfigPath +"/config.toml", &config); err != nil{
6258

6359
log.Fatal("Config file is missing: ", config)

exporter/metric/address.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ package metric
33
import (
44

55
"fmt"
6-
// "encoding/hex"
76
sdk "github.com/cosmos/cosmos-sdk/types"
8-
9-
// "github.com/node-a-team/terra-validator_exporter/getData"
10-
// cfg "github.com/node-a-team/terra-validator_exporter/config"
11-
// utils "github.com/node-a-team/terra-validator_exporter/utils"
127
)
138

149
var (

exporter/metric/metric.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ package metric
22

33
import (
44

5-
// "fmt"
6-
// "encoding/hex"
7-
// sdk "github.com/cosmos/cosmos-sdk/types"
85
"go.uber.org/zap"
96

10-
// "github.com/node-a-team/terra-validator_exporter/getData"
117
rest "github.com/node-a-team/terra-validator_exporter/getData/rest"
128
rpc "github.com/node-a-team/terra-validator_exporter/getData/rpc"
139
cfg "github.com/node-a-team/terra-validator_exporter/config"
@@ -121,7 +117,6 @@ func SetMetric(currentBlock int64, restData *rest.RESTData, rpcData *rpc.RPCData
121117
consAddr := restData.Validatorsets[consPubKey][0]
122118

123119
//// network
124-
125120
metricData.Network.ChainID = rpcData.Commit.ChainId
126121
metricData.Network.BlockHeight = currentBlock
127122

exporter/metric/types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ package metric
22

33
import (
44

5-
// "fmt"
6-
// "encoding/hex"
7-
// sdk "github.com/cosmos/cosmos-sdk/types"
8-
95
"github.com/prometheus/client_golang/prometheus"
106
)
117

getData/prometheus/prometheus.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

getData/rest/balances.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package rest
22

33
import (
4-
// "fmt"
54
"strings"
65
"go.uber.org/zap"
76
"encoding/json"

getData/rest/rest.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ func GetData(blockHeight int64, log *zap.Logger) (*RESTData, string) {
6363
func runRESTCommand(str string) ([]uint8, error) {
6464
cmd := "curl -s -XGET " +Addr +str +" -H \"accept:application/json\""
6565
out, err := exec.Command("/bin/bash", "-c", cmd).Output()
66-
// fmt.Println(cmd)
6766

6867
return out, err
6968
}

getData/rest/stakingPool.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ func getStakingPool(log *zap.Logger) stakingPool {
2626

2727
var sp stakingPool
2828

29-
res, _ := runRESTCommand("/staking/pool")
29+
res, err := runRESTCommand("/staking/pool")
3030
json.Unmarshal(res, &sp)
3131

3232
// log
3333
if strings.Contains(string(res), "not found") {
3434
// handle error
3535
log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),))
36-
} else {
36+
} else if err != nil {
37+
log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", "Failed to connect to REST-Server"),)
38+
} else {
3739
log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Staking Pool"),)
3840
}
3941

getData/rest/validators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func getValidators(log *zap.Logger) validator {
4848
if strings.Contains(string(res), "not found") {
4949
// handle error
5050
log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),))
51-
} else {
51+
} else {
5252
log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Validators"),)
5353
}
5454

main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ var ()
2020

2121
func main() {
2222

23-
port := "26661"
24-
2523
log,_ := zap.NewDevelopment()
2624
defer log.Sync()
2725

@@ -36,7 +34,7 @@ func main() {
3634

3735
cfg.ConfigPath = os.Args[1]
3836

39-
cfg.Init()
37+
port := cfg.Init()
4038
rpc.OpenSocket(log)
4139

4240
http.Handle("/metrics", promhttp.Handler())
@@ -51,5 +49,4 @@ func main() {
5149
log.Info("HTTP Handle", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Listen&Serve", "Prometheus Handler(Port: " +port +")"),)
5250
}
5351

54-
// utils.Log(err, "Http Handle", "", "")
5552
}

0 commit comments

Comments
 (0)