diff --git a/config.toml b/config.toml index 07db1f1..410824e 100644 --- a/config.toml +++ b/config.toml @@ -1,19 +1,14 @@ -# TOML Document for Cosmos-Validator Exporter(Pometheus & Grafana) +# TOML Document for Terra-Validator Exporter(Pometheus & Grafana) -title = "Cosmos-Validator Exporter TOML" -network = "cosmos" +title = "TOML Document" -# RPC-Server -[rpc] -address = "localhost:26657" +[Servers] + [Servers.addr] + rpc = "localhost:26657" + rest = "localhost:1317" -# Rest-server -[rest_server] -address = "localhost:1317" +[Validator] +operatorAddr = "cosmosvaloper14l0fp639yudfl46zauvv8rkzjgd4u0zk2aseys" -[validator_info] -operatorAddress = "cosmosvaloper14l0fp639yudfl46zauvv8rkzjgd4u0zk2aseys" - -[option] -exporterListenPort = "26661" -outputPrint = true +[Options] +listenPort = "26661" diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..59ecc6a --- /dev/null +++ b/config/config.go @@ -0,0 +1,68 @@ +package config + +import ( + "log" +// "time" + + "github.com/BurntSushi/toml" + rpc "github.com/node-a-team/cosmos-validator_exporter/getData/rpc" + rest "github.com/node-a-team/cosmos-validator_exporter/getData/rest" +// "github.com/spf13/viper" +) + +const ( +) + +var ( + ConfigPath string + Config configType +) + + +type configType struct { + + Title string `json:"title"` + + Servers struct { + Addr struct { + RPC string `json:"rpc"` + REST string `json:"rest"` + } + } + + Validator struct { + OperatorAddr string `json:"operatorAddr"` + } + + Options struct { + ListenPort string `json:"listenPort"` + } +} + + +func Init() { + + Config = readConfig() + + rpc.Addr = Config.Servers.Addr.RPC + rest.Addr = Config.Servers.Addr.REST + + rest.OperAddr = Config.Validator.OperatorAddr + +} + +func readConfig() configType { + + var config configType + +// path := viper.GetString(ConfigPath)+"/config.toml" + +// if _, err := toml.DecodeFile(path, &config); err != nil{ + if _, err := toml.DecodeFile(ConfigPath +"/config.toml", &config); err != nil{ + + log.Fatal("Config file is missing: ", config) + } + + return config + +} diff --git a/exporter/exporter.go b/exporter/exporter.go new file mode 100644 index 0000000..2bb5ef9 --- /dev/null +++ b/exporter/exporter.go @@ -0,0 +1,161 @@ +package exporter + +import ( + "fmt" + "time" + "go.uber.org/zap" + + rpc "github.com/node-a-team/cosmos-validator_exporter/getData/rpc" + rest "github.com/node-a-team/cosmos-validator_exporter/getData/rest" + metric "github.com/node-a-team/cosmos-validator_exporter/exporter/metric" + utils "github.com/node-a-team/cosmos-validator_exporter/utils" + + "github.com/prometheus/client_golang/prometheus" +) + +var ( + previousBlockHeight int64 + +) + +func Start(log *zap.Logger) { + + gaugesNamespaceList := metric.GaugesNamespaceList + + var gauges []prometheus.Gauge = make([]prometheus.Gauge, len(gaugesNamespaceList)) + var gaugesDenom []prometheus.Gauge = make([]prometheus.Gauge, len(metric.DenomList)*3) // wallet, rewards, commission + + + // nomal guages + for i := 0; i < len(gaugesNamespaceList); i++ { + gauges[i] = metric.NewGauge("exporter", gaugesNamespaceList[i], "") + prometheus.MustRegister(gauges[i]) + } + + + // denom gagues + count := 0 + for i := 0; i < len(metric.DenomList)*3; i += 3 { + gaugesDenom[i] = metric.NewGauge("exporter_balances", metric.DenomList[count], "") + gaugesDenom[i+1] = metric.NewGauge("exporter_commission", metric.DenomList[count], "") + gaugesDenom[i+2] = metric.NewGauge("exporter_rewards", metric.DenomList[count], "") + prometheus.MustRegister(gaugesDenom[i]) + prometheus.MustRegister(gaugesDenom[i+1]) + prometheus.MustRegister(gaugesDenom[i+2]) + + count++ + } + + + // labels + labels := []string{"chainId", "moniker", "operatorAddress", "accountAddress", "consHexAddress"} + gaugesForLabel := metric.NewCounterVec("exporter", "labels", "", labels) + + prometheus.MustRegister(gaugesForLabel) + + + for { + func() { + defer func() { + + if r := recover(); r != nil { + //Error Log + } + + time.Sleep(500 * time.Millisecond) + + }() + + + currentBlockHeight := rpc.BlockHeight() + + if previousBlockHeight != currentBlockHeight { + + log.Info("RPC-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Block Height: " +fmt.Sprint(currentBlockHeight))) + + + restData, consHexAddr := rest.GetData(currentBlockHeight, log) + rpcData := rpc.GetData(currentBlockHeight, consHexAddr, log) + + metric.SetMetric(currentBlockHeight, restData, rpcData, log) + + metricData := metric.GetMetric() + denomList := metric.GetDenomList() + + count := 0 + for i := 0; i < len(denomList); i++ { + + for _, value := range metricData.Validator.Account.Balances { + if value.Denom == denomList[i] { + gaugesDenom[count].Set(utils.StringToFloat64(value.Amount)) + count++ + } + } + for _, value := range metricData.Validator.Account.Commission { + if value.Denom == denomList[i] { + gaugesDenom[count].Set(utils.StringToFloat64(value.Amount)) + count++ + } + } + for _, value := range metricData.Validator.Account.Rewards { + if value.Denom == denomList[i] { + gaugesDenom[count].Set(utils.StringToFloat64(value.Amount)) + count++ + } + } + } + + + gaugesValue := [...]float64{ + float64(metricData.Network.BlockHeight), + + metricData.Network.Staking.NotBondedTokens, + metricData.Network.Staking.BondedTokens, + metricData.Network.Staking.TotalSupply, + metricData.Network.Staking.BondedRatio, + + metricData.Network.Gov.TotalProposalCount, + metricData.Network.Gov.VotingProposalCount, + + metricData.Validator.VotingPower, + metricData.Validator.MinSelfDelegation, + metricData.Validator.JailStatus, + + metricData.Validator.Proposer.Ranking, + metricData.Validator.Proposer.Status, + + metricData.Validator.Delegation.Shares, + metricData.Validator.Delegation.Ratio, + metricData.Validator.Delegation.DelegatorCount, + metricData.Validator.Delegation.Self, + + metricData.Validator.Commission.Rate, + metricData.Validator.Commission.MaxRate, + metricData.Validator.Commission.MaxChangeRate, + metricData.Validator.Commit.VoteType, + metricData.Validator.Commit.PrecommitStatus, + + metricData.Network.Minting.Inflation, + metricData.Network.Minting.ActualInflation, + } + + for i := 0; i < len(gaugesNamespaceList); i++ { + gauges[i].Set(gaugesValue[i]) + } + + + gaugesForLabel.WithLabelValues(metricData.Network.ChainID, + metricData.Validator.Moniker, + metricData.Validator.Address.Operator, + metricData.Validator.Address.Account, + metricData.Validator.Address.ConsensusHex, + ).Add(0) + + } + + previousBlockHeight = currentBlockHeight + }() + } +} + + diff --git a/exporter/metric/address.go b/exporter/metric/address.go new file mode 100644 index 0000000..8e18fdc --- /dev/null +++ b/exporter/metric/address.go @@ -0,0 +1,32 @@ +package metric + +import ( + + "fmt" +// "encoding/hex" + sdk "github.com/cosmos/cosmos-sdk/types" + +// "github.com/node-a-team/terra-validator_exporter/getData" +// cfg "github.com/node-a-team/terra-validator_exporter/config" +// utils "github.com/node-a-team/terra-validator_exporter/utils" +) + +var ( + +) + +func GetAccAddrFromOperAddr(operAddr string) string { + + // Get HexAddress + hexAddr, err := sdk.ValAddressFromBech32(operAddr) + if err != nil { + // Error + } + + accAddr, err := sdk.AccAddressFromHex(fmt.Sprint(hexAddr)) + if err != nil { + // Error + } + + return accAddr.String() +} diff --git a/exporter/metric/metric.go b/exporter/metric/metric.go new file mode 100644 index 0000000..a82cb4c --- /dev/null +++ b/exporter/metric/metric.go @@ -0,0 +1,189 @@ +package metric + +import ( + +// "fmt" +// "encoding/hex" +// sdk "github.com/cosmos/cosmos-sdk/types" + "go.uber.org/zap" + + rest "github.com/node-a-team/cosmos-validator_exporter/getData/rest" + rpc "github.com/node-a-team/cosmos-validator_exporter/getData/rpc" + cfg "github.com/node-a-team/cosmos-validator_exporter/config" + utils "github.com/node-a-team/cosmos-validator_exporter/utils" +) + +var ( + metricData metric + + DenomList = []string{"uatom"} + GaugesNamespaceList = [...]string{"blockHeight", + "notBondedTokens", + "bondedTokens", + "totalSupply", + "bondedRatio", + "totalProposalCount", + "votingProposalCount", + "votingPower", + "minSelfDelegation", + "jailStatus", + "proposerRanking", + "proposerStatus", + "delegationShares", + "delegationRatio", + "delegatorCount", + "delegationSelf", + "commissionRate", + "commissionMaxRate", + "commissionMaxChangeRate", + "commitVoteType", + "precommitStatus", + "inflation", + "actualInflation", + } +) + +type metric struct { + + Network struct { + ChainID string + BlockHeight int64 + PrecommitRate float64 + + Staking struct { + NotBondedTokens float64 + BondedTokens float64 + TotalSupply float64 + BondedRatio float64 + } + + Minting struct { + Inflation float64 + ActualInflation float64 + } + + Gov struct{ + TotalProposalCount float64 + VotingProposalCount float64 + } + } + + Validator struct { + Moniker string + VotingPower float64 + MinSelfDelegation float64 + JailStatus float64 + + + + Address struct { + Account string + Operator string + ConsensusHex string + } + Proposer struct { + Ranking float64 + Status float64 + } + + Delegation struct { + Shares float64 + Ratio float64 + DelegatorCount float64 + Self float64 + } + + Commission struct { + Rate float64 + MaxRate float64 + MaxChangeRate float64 + } + + Account struct { + Balances []rest.Coin + Commission []rest.Coin + Rewards []rest.Coin + } + + Commit struct { + VoteType float64 + PrecommitStatus float64 + } + + } +} + + + +func SetMetric(currentBlock int64, restData *rest.RESTData, rpcData *rpc.RPCData, log *zap.Logger) { + + operAddr := cfg.Config.Validator.OperatorAddr + consPubKey := restData.Validators.ConsPubKey + consAddr := restData.Validatorsets[consPubKey][0] + + //// network + + metricData.Network.ChainID = rpcData.Commit.ChainId + metricData.Network.BlockHeight = currentBlock + + metricData.Network.Staking.NotBondedTokens = utils.StringToFloat64(restData.StakingPool.Result.Not_bonded_tokens) + metricData.Network.Staking.BondedTokens = utils.StringToFloat64(restData.StakingPool.Result.Bonded_tokens) + metricData.Network.Staking.TotalSupply = restData.StakingPool.Result.Total_supply + metricData.Network.Staking.BondedRatio = metricData.Network.Staking.BondedTokens / metricData.Network.Staking.TotalSupply + + // minting + metricData.Network.Minting.Inflation = restData.Inflation + metricData.Network.Minting.ActualInflation = metricData.Network.Minting.Inflation / metricData.Network.Staking.BondedRatio + + // gov + metricData.Network.Gov.TotalProposalCount = restData.Gov.TotalProposalCount + metricData.Network.Gov.VotingProposalCount = restData.Gov.VotingProposalCount + + + //// validator + metricData.Validator.Moniker = restData.Validators.Description.Moniker + metricData.Validator.VotingPower = utils.StringToFloat64(restData.Validatorsets[consPubKey][1]) + metricData.Validator.MinSelfDelegation = utils.StringToFloat64(restData.Validators.MinSelfDelegation) + metricData.Validator.JailStatus = utils.BoolToFloat64(restData.Validators.Jailed) + + // address + metricData.Validator.Address.Operator = operAddr + metricData.Validator.Address.Account = utils.GetAccAddrFromOperAddr(operAddr, log) + metricData.Validator.Address.ConsensusHex = utils.Bech32AddrToHexAddr(consAddr, log) + + // proposer + metricData.Validator.Proposer.Ranking = utils.StringToFloat64(restData.Validatorsets[consPubKey][3]) + metricData.Validator.Proposer.Status = rpcData.Commit.ValidatorProposingStatus + + // delegation + metricData.Validator.Delegation.Shares = utils.StringToFloat64(restData.Validators.DelegatorShares) + metricData.Validator.Delegation.Ratio = metricData.Validator.Delegation.Shares / metricData.Network.Staking.BondedTokens + metricData.Validator.Delegation.DelegatorCount = restData.Delegations.DelegationCount + metricData.Validator.Delegation.Self = restData.Delegations.SelfDelegation + + // commission + metricData.Validator.Commission.Rate = utils.StringToFloat64(restData.Validators.Commission.Commission_rates.Rate) + metricData.Validator.Commission.MaxRate = utils.StringToFloat64(restData.Validators.Commission.Commission_rates.Max_rate) + metricData.Validator.Commission.MaxChangeRate = utils.StringToFloat64(restData.Validators.Commission.Commission_rates.Max_change_rate) + + // account + metricData.Validator.Account.Balances = restData.Balances + metricData.Validator.Account.Commission = restData.Commission + metricData.Validator.Account.Rewards = restData.Rewards + + // commit + metricData.Validator.Commit.VoteType = rpcData.Commit.VoteType + metricData.Validator.Commit.PrecommitStatus = rpcData.Commit.ValidatorPrecommitStatus + + + +} + +func GetMetric() *metric { + + return &metricData +} + +func GetDenomList() []string { + return DenomList +} diff --git a/exporter/metric/types.go b/exporter/metric/types.go new file mode 100644 index 0000000..828a54d --- /dev/null +++ b/exporter/metric/types.go @@ -0,0 +1,39 @@ +package metric + +import ( + +// "fmt" +// "encoding/hex" +// sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/prometheus/client_golang/prometheus" +) + +var ( + +) + +func NewGauge(nameSpace string, name string, help string) prometheus.Gauge { + result := prometheus.NewGauge( + prometheus.GaugeOpts{ + Namespace: "" + nameSpace, + Name: "" + name, + Help: "" + help, + }, + ) + + return result +} + +func NewCounterVec(nameSpace string, name string, help string, labels []string) prometheus.CounterVec { + result := prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: "" + nameSpace, + Name: "" + name, + Help: "" + help, + }, + labels, + ) + return *result +} + diff --git a/getData/prometheus/prometheus.go b/getData/prometheus/prometheus.go new file mode 100644 index 0000000..628408d --- /dev/null +++ b/getData/prometheus/prometheus.go @@ -0,0 +1,33 @@ +package prometheus + +import ( + +// "fmt" + "os/exec" +// "encoding/json" +// "regexp" +) + +var ( + addr string = "localhost:26660" + PMetric string +) + + +func GetPrometheusMetric() { + +// check := "tendermint_consensus_block_interval_seconds" +// check = "tendermint_p2p_peer_send_bytes_total" + + cmd := "curl -s -XGET " +addr + out, _ := exec.Command("/bin/bash", "-c", cmd).Output() + PMetric = string(out) + +/* + re, _ := regexp.Compile(check +"{[0-9a-zA-Z-_.,\\\"=]+}" +"\\s" + "[0-9]+(.)[0-9]+") + str := re.FindString(string(out)) + fmt.Println(str) + fmt.Println(string(out)) +*/ +} + diff --git a/getData/rest/balances.go b/getData/rest/balances.go new file mode 100644 index 0000000..0f66ecd --- /dev/null +++ b/getData/rest/balances.go @@ -0,0 +1,35 @@ +package rest + +import ( +// "fmt" + "strings" + "go.uber.org/zap" + "encoding/json" +) + +type balances struct { + Height string `json:"height"` + Result []Coin +} + +type Coin struct { + Denom string + Amount string +} + +func getBalances(accAddr string, log *zap.Logger) []Coin { + + var b balances + + res, _ := runRESTCommand("/bank/balances/" +accAddr) + json.Unmarshal(res, &b) + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Staking Pool"),) + } + + return b.Result +} diff --git a/getData/rest/delegations.go b/getData/rest/delegations.go new file mode 100644 index 0000000..c2e99ab --- /dev/null +++ b/getData/rest/delegations.go @@ -0,0 +1,51 @@ +package rest + +import ( + "strings" + "go.uber.org/zap" + "encoding/json" + utils "github.com/node-a-team/cosmos-validator_exporter/utils" +) + +type delegations struct { + Height string `json:"height"` + Result []delegation +} + +type delegation struct { + Delegator_address string `json:"delegator_address"` + Validator_address string `json:"validator_address"` + Shares string `json:"shares"` + Balance string `json:"balance"` +} + +type delegationInfo struct { + DelegationCount float64 + SelfDelegation float64 +} + +func getDelegations(accAddr string, log *zap.Logger) delegationInfo { + + var d delegations + var dInfo delegationInfo + + res, _ := runRESTCommand("/staking/validators/" +OperAddr +"/delegations") + json.Unmarshal(res, &d) + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Delegations"),) + } + + dInfo.DelegationCount = float64(len(d.Result)) + + for _, value := range d.Result { + if accAddr == value.Delegator_address { + dInfo.SelfDelegation = utils.StringToFloat64(value.Shares) + } + } + + return dInfo +} diff --git a/getData/rest/gov.go b/getData/rest/gov.go new file mode 100644 index 0000000..80a9782 --- /dev/null +++ b/getData/rest/gov.go @@ -0,0 +1,73 @@ +package rest + +import ( + "strings" + "go.uber.org/zap" + "encoding/json" +) + +type govInfo struct { + TotalProposalCount float64 + VotingProposalCount float64 +} + + +type gov struct { + Height string + Result []proposal +} + +type proposal struct { + Content struct { + Type string + Value struct { + Title string + Description string + } + + } + Id string + Proposal_status string + Final_tally_result struct { + Yes string + Abstain string + No string + No_with_veto string + } + + Submit_time string + Deposit_end_time string + Total_deposit string + Voting_start_time string + Voting_end_time string + +} + +func getGovInfo(log *zap.Logger) govInfo { + + var g gov + var gi govInfo + + votingCount := 0 + + res, _ := runRESTCommand("/gov/proposals") + json.Unmarshal(res, &g) + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Governance"),) + } + + for _, value := range g.Result { + if value.Proposal_status == "VotingPeriod" { + votingCount++ + } + } + + gi.TotalProposalCount = float64(len(g.Result)) + gi.VotingProposalCount = float64(votingCount) + + return gi +} diff --git a/getData/rest/inflation.go b/getData/rest/inflation.go new file mode 100644 index 0000000..62bda83 --- /dev/null +++ b/getData/rest/inflation.go @@ -0,0 +1,32 @@ +package rest + +import ( + "strings" + "go.uber.org/zap" + "encoding/json" + + utils "github.com/node-a-team/cosmos-validator_exporter/utils" +) + +type inflation struct { + Height string `json:"height"` + Result string `json:"result"` +} + +func getInflation(log *zap.Logger) float64 { + + var i inflation + + res, _ := runRESTCommand("/minting/inflation") + json.Unmarshal(res, &i) + + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Inflation"),) + } + + return utils.StringToFloat64(i.Result) +} diff --git a/getData/rest/rest.go b/getData/rest/rest.go new file mode 100644 index 0000000..ccae21e --- /dev/null +++ b/getData/rest/rest.go @@ -0,0 +1,69 @@ +package rest + +import ( + "go.uber.org/zap" + "os/exec" + + utils "github.com/node-a-team/cosmos-validator_exporter/utils" +) + +var ( + Addr string + OperAddr string +) + + +type RESTData struct { + + BlockHeight int64 + StakingPool stakingPool + + Validatorsets map[string][]string + Validators validator + Delegations delegationInfo + Balances []Coin + Rewards []Coin + Commission []Coin + Inflation float64 + + Gov govInfo +} + +func newRESTData(blockHeight int64) *RESTData { + + rd := &RESTData { + BlockHeight: blockHeight, + Validatorsets: make(map[string][]string), + } + + return rd +} + +func GetData(blockHeight int64, log *zap.Logger) (*RESTData, string) { + + + accAddr := utils.GetAccAddrFromOperAddr(OperAddr, log) + + rd := newRESTData(blockHeight) + rd.StakingPool = getStakingPool(log) + rd.Inflation = getInflation(log) + + rd.Validatorsets = getValidatorsets(blockHeight, log) + rd.Validators = getValidators(log) + rd.Delegations = getDelegations(accAddr, log) + rd.Balances = getBalances(accAddr, log) + rd.Rewards, rd.Commission = getRewardsAndCommisson(log) + + rd.Gov = getGovInfo(log) + + consHexAddr := utils.Bech32AddrToHexAddr(rd.Validatorsets[rd.Validators.ConsPubKey][0], log) + return rd, consHexAddr +} + +func runRESTCommand(str string) ([]uint8, error) { + cmd := "curl -s -XGET " +Addr +str +" -H \"accept:application/json\"" + out, err := exec.Command("/bin/bash", "-c", cmd).Output() +// fmt.Println(cmd) + + return out, err +} diff --git a/getData/rest/rewardsAndCommission.go b/getData/rest/rewardsAndCommission.go new file mode 100644 index 0000000..c55a1c6 --- /dev/null +++ b/getData/rest/rewardsAndCommission.go @@ -0,0 +1,35 @@ +package rest + +import ( + "strings" + "go.uber.org/zap" + "encoding/json" +) + +type rewardsAndCommisson struct { + + Height string `json:"height"` + Result struct { + Operator_Address string `"json:"operator_address"` + Self_bond_rewards []Coin `"json:"self_bond_rewards"` + Val_commission []Coin `"json:"val_commission"` + } + +} + +func getRewardsAndCommisson(log *zap.Logger) ([]Coin, []Coin) { + + var rc rewardsAndCommisson + + res, _ := runRESTCommand("/distribution/validators/" +OperAddr) + json.Unmarshal(res, &rc) + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Rewards&Commission"),) + } + + return rc.Result.Self_bond_rewards, rc.Result.Val_commission +} diff --git a/getData/rest/stakingPool.go b/getData/rest/stakingPool.go new file mode 100644 index 0000000..61a7946 --- /dev/null +++ b/getData/rest/stakingPool.go @@ -0,0 +1,61 @@ +package rest + +import ( + "strings" + "go.uber.org/zap" + "encoding/json" + + utils "github.com/node-a-team/cosmos-validator_exporter/utils" +) + +type stakingPool struct { + Height string `json:"height"` + Result struct { + Not_bonded_tokens string `json:"not_bonded_tokens"` + Bonded_tokens string `json:"bonded_tokens"` + Total_supply float64 + } +} + +type totalSupply struct { + Height string `json:"height"` + Result string `json:"result"` +} + +func getStakingPool(log *zap.Logger) stakingPool { + + var sp stakingPool + + res, _ := runRESTCommand("/staking/pool") + json.Unmarshal(res, &sp) + + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Staking Pool"),) + } + + sp.Result.Total_supply = getTotalSupply("atom", log) + + return sp +} + +func getTotalSupply(denom string, log *zap.Logger) float64 { + + var ts totalSupply + + res, _ := runRESTCommand("/supply/total/u" +denom) + json.Unmarshal(res, &ts) + + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Total Supply"),) + } + + return utils.StringToFloat64(ts.Result) +} diff --git a/getData/rest/validators.go b/getData/rest/validators.go new file mode 100644 index 0000000..7a6e499 --- /dev/null +++ b/getData/rest/validators.go @@ -0,0 +1,56 @@ +package rest + +import ( + "strings" + "encoding/json" + "go.uber.org/zap" +) + +type validators struct { + Height string `json:"height"` + Result validator +} + +type validator struct { + OperAddr string `json:"operator_address"` + ConsPubKey string `json:"consensus_pubkey"` + Jailed bool `json:"jailed"` + Status int `json:"status"` + Tokens string `json:"tokens"` + DelegatorShares string `json:"delegator_shares"` + Description struct { + Moniker string `json:"moniker"` + Identity string `json:"identity"` + Website string `json:"website"` + Details string `json:"details"` + } + UnbondingHeight string `json:"unbonding_height"` + UnbondingTime string `json:"unbonding_time"` + Commission struct { + Commission_rates struct { + Rate string `json:"rate"` + Max_rate string `json:"max_rate"` + Max_change_rate string `json:"max_change_rate"` + } + UpdateTime string `json:"update_time"` + } + MinSelfDelegation string `json:"min_self_delegation"` +} + +func getValidators(log *zap.Logger) validator { + + var v validators + + res, _ := runRESTCommand("/staking/validators/" +OperAddr) + json.Unmarshal(res, &v) + + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Validators"),) + } + + return v.Result +} diff --git a/getData/rest/validatorsets.go b/getData/rest/validatorsets.go new file mode 100644 index 0000000..9d75a7b --- /dev/null +++ b/getData/rest/validatorsets.go @@ -0,0 +1,75 @@ +package rest + +import ( + "fmt" + "encoding/json" + "sort" + "strconv" + "go.uber.org/zap" + "strings" +) + +type validatorsets struct { + + Height string `json:"height"` + + Result struct { + Block_Height string `json:"block_height"` + Validators []struct { + ConsAddr string `json:"address"` + ConsPubKey string `json:"pub_key"` + ProposerPriority string `json:"proposer_priority"` + VotingPower string `json:"voting_power"` + } + + } +} + +func getValidatorsets(currentBlockHeight int64, log *zap.Logger) map[string][]string { + + var vSets validatorsets + var vSetsResult map[string][]string = make(map[string][]string) + + res, _ := runRESTCommand("/validatorsets/" +fmt.Sprint(currentBlockHeight)) + json.Unmarshal(res, &vSets) + + // log + if strings.Contains(string(res), "not found") { + // handle error + log.Fatal("REST-Server", zap.Bool("Success", false), zap.String("err", string(res),)) + } else { + log.Info("REST-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Validatorsets"),) + } + + + + for _, value := range vSets.Result.Validators { + // address, voting_power, proposer_priority, proposer_ranking + vSetsResult[value.ConsPubKey] = []string{value.ConsAddr, value.VotingPower, value.ProposerPriority, "0"} + } + + return Sort(vSetsResult) +} + +func Sort(mapValue map[string][]string) map[string][]string { + + keys := []string{} + newMapValue := mapValue + + for key := range mapValue { + keys = append(keys, key) + } + + // Sort by proposer_priority + sort.Slice(keys, func(i, j int) bool { + a, _ := strconv.Atoi(mapValue[keys[i]][2]) + b, _ := strconv.Atoi(mapValue[keys[j]][2]) + return a > b + }) + + for i, key := range keys { + // proposer_ranking + newMapValue[key][3] = strconv.Itoa(i + 1) + } + return newMapValue +} diff --git a/getData/rpc/commit.go b/getData/rpc/commit.go new file mode 100644 index 0000000..88d180d --- /dev/null +++ b/getData/rpc/commit.go @@ -0,0 +1,51 @@ +package rpc + +import ( + "fmt" + ctypes "github.com/tendermint/tendermint/rpc/core/types" +) + +type commitInfo struct { + ChainId string + VoteType float64 // [0]: false, [1]: prevote, [2]: precommit + ValidatorPrecommitStatus float64 // [0]: false, [1]: true + ValidatorProposingStatus float64 // [0]: false, [1]: true +} + +func getCommit(commitData *ctypes.ResultCommit, consHexAddr string) commitInfo { + + var cInfo commitInfo + + blockProposer := fmt.Sprint(commitData.SignedHeader.Header.ProposerAddress) + + cInfo.ChainId = commitData.SignedHeader.Header.ChainID + cInfo.VoteType, cInfo.ValidatorPrecommitStatus, cInfo.ValidatorProposingStatus = 0.0, 0.0, 0.0 + + for _, v := range commitData.SignedHeader.Commit.Precommits { + + func() { + defer func() { + + if r := recover(); r != nil { + // precommit failure validator + } + }() + + if consHexAddr == fmt.Sprint(v.ValidatorAddress) { + + cInfo.VoteType = float64(v.Type) + + if v.Type == 2 { + cInfo.ValidatorPrecommitStatus = 1.0 + } + } + + if consHexAddr == blockProposer { + cInfo.ValidatorProposingStatus = 1.0 + } + }() + + } + + return cInfo +} diff --git a/getData/rpc/rpc.go b/getData/rpc/rpc.go new file mode 100644 index 0000000..c451a76 --- /dev/null +++ b/getData/rpc/rpc.go @@ -0,0 +1,78 @@ +package rpc + +import ( + "fmt" + "go.uber.org/zap" + + tmclient "github.com/tendermint/tendermint/rpc/client" +) + + +type RPCData struct { + Commit commitInfo +} + +var ( + Addr string + + Client *tmclient.HTTP +) + +func newRPCData() *RPCData { + + rd := &RPCData { + // + } + + return rd +} + +func GetData(blockHeight int64, consHexAddr string, log *zap.Logger) *RPCData { + + rd := newRPCData() + + var commitHeight int64 = blockHeight -1 + + commitData, err := Client.Commit(&commitHeight) + // log + if err != nil { + // handle error + log.Fatal("RPC-Server", zap.Bool("Success", false), zap.String("err", fmt.Sprint(err),)) + } else { + log.Info("RPC-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Get Data", "Commit Data"),) + } + + rd.Commit = getCommit(commitData, consHexAddr) + + + return rd +} + +func OpenSocket(log *zap.Logger) { + + Client = tmclient.NewHTTP("tcp://"+Addr, "/websocket") + + err := Client.Start() + + if err != nil { + // handle error + log.Fatal("RPC-Server", zap.Bool("Success", false), zap.String("err", fmt.Sprintf("%s", err)),) + } else { + log.Info("RPC-Server", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Open Socket", "tcp://" +Addr +"/websocket"),) + } + + + defer Client.Stop() + +} + +func BlockHeight() (res int64) { + + info, _:= Client.ABCIInfo() + + res = info.Response.LastBlockHeight + + return res +} + + diff --git a/go.mod b/go.mod index 3cf7bc9..8b2b6c4 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,11 @@ module github.com/node-a-team/cosmos-validator_exporter -go 1.12 +go 1.13 require ( github.com/BurntSushi/toml v0.3.1 - github.com/prometheus/client_golang v1.1.0 - github.com/tendermint/tendermint v0.32.3 + github.com/cosmos/cosmos-sdk v0.37.4 + github.com/prometheus/client_golang v1.3.0 + github.com/tendermint/tendermint v0.32.8 + go.uber.org/zap v1.13.0 ) diff --git a/go.sum b/go.sum index df65e52..8233694 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,21 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d/go.mod h1:icNx/6QdFblhsEjZehARqbNumymUT/ydwlLojFdv7Sk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d h1:xG8Pj6Y6J760xwETNmMzmlt38QSwz0BLp1cZ09g27uw= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= @@ -19,62 +26,113 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cosmos/cosmos-sdk v0.37.4 h1:1ioXxkpiS+wOgaUbROeDIyuF7hciU5nti0TSyBmV2Ok= +github.com/cosmos/cosmos-sdk v0.37.4/go.mod h1:Axr+Q+G2Ffduxt4zMA6KwxxvyVSKPB9+nXZVPKgpC2c= +github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/ledger-cosmos-go v0.10.3/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= +github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/etcd-io/bbolt v1.3.2/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= +github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= +github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/kit v0.6.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/libp2p/go-buffer-pool v0.0.1 h1:9Rrn/H46cXjaA2HQ5Y8lyhOS1NhTkZ4yuEs2r3Eechg= -github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= +github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -84,81 +142,181 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8= -github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= +github.com/prometheus/client_golang v1.3.0 h1:miYCvYqFXtl/J9FIy8eNpBfYthAEFg+Ys0XyUVEcDsc= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.1.0 h1:ElTg5tNp4DqfV7UQjDqv2+RJlNzsDtvNAWccbItceIE= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= -github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE= -github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rakyll/statik v0.1.5/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165 h1:nkcn14uNmFEuGCb2mBZbBb24RdNRL08b/wb+xBOYpuk= github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rs/cors v1.6.0 h1:G9tHG9lebljV9mfp9SNPDL36nCDxmo3zTlAf1YgvzmI= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.1/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stumble/gorocksdb v0.0.3/go.mod h1:v6IHdFBXk5DJ1K4FZ0xi+eY737quiiBxYtSWXadLybY= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 h1:1oFLiOyVl+W7bnBzGhf7BbIv9loSFQcieWWYIjLqcAw= github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= -github.com/tendermint/go-amino v0.14.1 h1:o2WudxNfdLNBwMyl2dqOJxiro5rfrEaU0Ugs6offJMk= +github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= +github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso= -github.com/tendermint/tendermint v0.32.3 h1:GEnWpGQ795h5oTFNbfBLsY0LW/CW2j6p6HtiYNfxsgg= -github.com/tendermint/tendermint v0.32.3/go.mod h1:ZK2c29jl1QRYznIRyRWRDsmm1yvtPzBRT00x4t1JToY= -github.com/tendermint/tm-db v0.1.1 h1:G3Xezy3sOk9+ekhjZ/kjArYIs1SmwV+1OUgNkj7RgV0= +github.com/tendermint/go-amino v0.15.0 h1:TC4e66P59W7ML9+bxio17CPKnxW3nKIRAYskntMAoRk= +github.com/tendermint/go-amino v0.15.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/iavl v0.12.4/go.mod h1:8LHakzt8/0G3/I8FUU0ReNx98S/EP6eyPJkAUvEXT/o= +github.com/tendermint/tendermint v0.32.1/go.mod h1:jmPDAKuNkev9793/ivn/fTBnfpA9mGBww8MPRNPNxnU= +github.com/tendermint/tendermint v0.32.7/go.mod h1:D2+A3pNjY+Po72X0mTfaXorFhiVI8dh/Zg640FGyGtE= +github.com/tendermint/tendermint v0.32.8 h1:eOaLJGRi5x/Rb23fiVsxq9c5fZ/6O5QplExlGjNPDVI= +github.com/tendermint/tendermint v0.32.8/go.mod h1:5/B1XZjNYtVBso8o1l/Eg4A0Mhu42lDcmftoQl95j/E= github.com/tendermint/tm-db v0.1.1/go.mod h1:0cPKWu2Mou3IlxecH+MEUSYc1Ch537alLe6CpFrKzgw= +github.com/tendermint/tm-db v0.2.0 h1:rJxgdqn6fIiVJZy4zLpY1qVlyD0TU6vhkT4kEf71TQQ= +github.com/tendermint/tm-db v0.2.0/go.mod h1:0cPKWu2Mou3IlxecH+MEUSYc1Ch537alLe6CpFrKzgw= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0 h1:sFPn2GLc3poCkfrpIXGhBD2X0CMIo4Q/zSULXrj/+uc= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3 h1:4y9KwBHBgBNwDbtu44R5o1fdOCQUEXhbk/P4A9WmJq0= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f h1:68K/z8GLUxV76xGSqwTWw2gyk/jwn79LUL43rES2g8o= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2 h1:67iHsV9djwGdZpdZNbLuQj6FOzCaZe3w+vhLjn5AcFA= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/grpc v1.22.0 h1:J0UbZOIrCAl+fpTOf8YLs4dJo8L/owV4LYVtAXQoPkw= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.13.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/main.go b/main.go index 8abb1de..6689bba 100644 --- a/main.go +++ b/main.go @@ -1,32 +1,52 @@ package main import ( - "log" + "fmt" "net/http" + "os" + "go.uber.org/zap" - t "github.com/node-a-team/cosmos-validator_exporter/types" - config "github.com/node-a-team/cosmos-validator_exporter/function/config" - websocket "github.com/node-a-team/cosmos-validator_exporter/function/websocket" - exporter "github.com/node-a-team/cosmos-validator_exporter/function/exporter" + sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/prometheus/client_golang/prometheus/promhttp" + "github.com/prometheus/client_golang/prometheus/promhttp" + + cfg "github.com/node-a-team/cosmos-validator_exporter/config" + "github.com/node-a-team/cosmos-validator_exporter/exporter" + rpc "github.com/node-a-team/cosmos-validator_exporter/getData/rpc" ) -var ( +const ( + bech32MainPrefix = "cosmos" +) +func main() { -) + port := "26661" + log,_ := zap.NewDevelopment() + defer log.Sync() + config := sdk.GetConfig() + config.SetBech32PrefixForAccount(bech32MainPrefix, bech32MainPrefix+sdk.PrefixPublic) + config.SetBech32PrefixForValidator(bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator, bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator+sdk.PrefixPublic) + config.SetBech32PrefixForConsensusNode(bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus, bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus+sdk.PrefixPublic) -func main() { + cfg.ConfigPath = os.Args[1] - http.Handle("/metrics", promhttp.Handler()) + cfg.Init() + rpc.OpenSocket(log) - config.Init() - websocket.OpenSocket() + http.Handle("/metrics", promhttp.Handler()) + go exporter.Start(log) - go exporter.Exporter() + err := http.ListenAndServe(":" +port, nil) + // log + if err != nil { + // handle error + log.Fatal("HTTP Handle", zap.Bool("Success", false), zap.String("err", fmt.Sprint(err),)) + } else { + log.Info("HTTP Handle", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Listen&Serve", "Prometheus Handler(Port: " +port +")"),) + } - log.Fatal(http.ListenAndServe(":"+t.ExporterListenPort, nil)) - } +// utils.Log(err, "Http Handle", "", "") +} diff --git a/utils/address.go b/utils/address.go new file mode 100644 index 0000000..1b01bfa --- /dev/null +++ b/utils/address.go @@ -0,0 +1,70 @@ +package utils + +import ( + "fmt" + "go.uber.org/zap" + + "github.com/tendermint/tendermint/libs/bech32" + + sdk "github.com/cosmos/cosmos-sdk/types" + +) + +const ( + bech32MainPrefix = "cosmos" +) + +var ( + Bech32Prefixes = []string{ + // account's address + bech32MainPrefix, + // account's public key + bech32MainPrefix+sdk.PrefixPublic, + // validator's operator address + bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator, + // validator's operator public key + bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator+sdk.PrefixPublic, + // consensus node address + bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus, + // consensus node public key + bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus+sdk.PrefixPublic, + } +) + +// Bech32 Addr -> Hex Addr +func Bech32AddrToHexAddr(bech32str string, log *zap.Logger) string { + _, bz, err := bech32.DecodeAndConvert(bech32str) + if err != nil { + // handle error + log.Fatal("Utils-Address", zap.Bool("Success", false), zap.String("err", fmt.Sprint(err),)) + } else { +// log.Info("Utils-Address", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Change Address", "Bech32Addr To HexAddr"),) + } + + return fmt.Sprintf("%X", bz) +} + +func GetAccAddrFromOperAddr(operAddr string, log *zap.Logger) string { + + // Get HexAddress + hexAddr, err := sdk.ValAddressFromBech32(operAddr) + // log + if err != nil { + // handle error + log.Fatal("Utils-Address", zap.Bool("Success", false), zap.String("err", fmt.Sprint(err),)) + } else { +// log.Info("Utils-Address", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Change Address", "OperAddr To HexAddr"),) + } + + accAddr, err := sdk.AccAddressFromHex(fmt.Sprint(hexAddr)) + // log + if err != nil { + // handle error + log.Fatal("Utils-Address", zap.Bool("Success", false), zap.String("err", fmt.Sprint(err),)) + } else { +// log.Info("Utils-Address", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Change Address", "HexAddr To AccAddr"),) + } + + return accAddr.String() +} + diff --git a/utils/converter.go b/utils/converter.go new file mode 100644 index 0000000..c12986b --- /dev/null +++ b/utils/converter.go @@ -0,0 +1,27 @@ +package utils + +import ( + "strconv" +) + +func StringToFloat64(str string) float64 { + + var result float64 + + result, _ = strconv.ParseFloat(str, 64) + + return result +} + +func BoolToFloat64(b bool) float64 { + + var result float64 + + if b == true { + result = 1 + } else { + result = 0 + } + + return result +}