diff --git a/function/commit/commit.go_origin b/function/commit/commit.go_origin deleted file mode 100644 index 8f3cbee..0000000 --- a/function/commit/commit.go_origin +++ /dev/null @@ -1,67 +0,0 @@ -package commit - -import ( - t "github.com/node-a-team/cosmos-validator_exporter/types" - - "encoding/json" - "fmt" -// "os/exec" -) - -func CommitStatus(blockHeight int) t.CommitStatus { - - var commitStatus t.CommitStatus - - var blockHeightInt64 int64 = int64(blockHeight) - - info, _ := t.Client.Commit(&blockHeightInt64) - result, _ := json.Marshal(info) - - -// cmd := "curl -s -XGET " + t.RpcServer + "/commit?height=" + fmt.Sprint(blockHeight) + " -H \"accept:application/json\"" -// out, _ := exec.Command("/bin/bash", "-c", cmd).Output() -// json.Unmarshal(out, &commitStatus) - - json.Unmarshal(result, &commitStatus) - fmt.Println(commitStatus) - - return commitStatus - -} - -func ValidatorPrecommitStatus(commitStatus t.CommitStatus, consHexAddr string) int { - - // validatorCommitStatus(0: false, 1 : true) - validatorCommitStatus := 0 - - precommitData := commitStatus.Result.Signed_header.Commit.Precommits - - for _, value := range precommitData { - - if value.Validator_address == consHexAddr { - validatorCommitStatus = 1 - } - } - - return validatorCommitStatus -} - -func PrecommitRate(commitStatus t.CommitStatus) float64 { - - // validatorCommitStatus(0: false, 1 : true) - precommitRate := 0.0 - - precommitData := commitStatus.Result.Signed_header.Commit.Precommits - totalCount, precommitCount := len(precommitData), len(precommitData) - - for _, value := range precommitData { - - if value.Validator_address == "" { - precommitCount-- - } - } - - precommitRate = float64(precommitCount) / float64(totalCount) - - return precommitRate -} diff --git a/function/config/config.go_origin b/function/config/config.go_origin deleted file mode 100644 index 5d46c61..0000000 --- a/function/config/config.go_origin +++ /dev/null @@ -1,65 +0,0 @@ -package config - -import ( - - t "github.com/node-a-team/cosmos-validator_exporter/types" - - "fmt" - "time" - "os" - "log" - - "github.com/BurntSushi/toml" -) - - -func Init() { - - var config = readConfig() - - fmt.Printf("\033[7m##### %s #####\033[0m\n", config.Title) - - t.RpcServer = config.Rpc.Address - t.RestServer = config.Rest_server.Address - - t.OperatorAddr = config.Validator_info.OperatorAddress - t.ExporterListenPort = config.Option.ExporterListenPort - t.OutputPrint = config.Option.OutputPrint - t.Bech32MainPrefix = config.Network - - fmt.Println("\n[ Your Info ]") - fmt.Println("- Network:", config.Network) - fmt.Println("- RPC Server Address:", config.Rpc.Address) - fmt.Println("- Rest Server Address:", config.Rest_server.Address) - fmt.Println("- Validator Operator Address:", config.Validator_info.OperatorAddress) - fmt.Println("- Exporter Listen Port:", config.Option.ExporterListenPort) - fmt.Printf("- Output Print: %v\n\n", config.Option.OutputPrint) - - - fmt.Printf("\033[32m## Start Exporter\033[0m\n\n") - - fmt.Printf("\033[34m## This exporter was created by \"Node A-Team\"\n") - fmt.Printf("## Validator: https://www.mintscan.io/validators/cosmosvaloper14l0fp639yudfl46zauvv8rkzjgd4u0zk2aseys\n") - fmt.Printf("## Git: https://github.com/node-a-team/cosmos-validator_exporter.git\033[0m\n\n") - - time.Sleep(1*time.Second) -} - -func readConfig() t.Config { - - var configfile string = "config.toml" - var config t.Config - - _, err := os.Stat(configfile) - - if err != nil { - log.Fatal("Config file is missing: ", configfile) - } - - if _, err := toml.DecodeFile(configfile, &config); err != nil { - log.Fatal(err) - } - - return config - -} diff --git a/types/.block.go.swp b/types/.block.go.swp deleted file mode 100644 index 0d78446..0000000 Binary files a/types/.block.go.swp and /dev/null differ diff --git a/types/commit.go_origin b/types/commit.go_origin deleted file mode 100644 index 6ac4140..0000000 --- a/types/commit.go_origin +++ /dev/null @@ -1,41 +0,0 @@ -package types - -import ( - "time" -) - -type CommitStatus struct { - Result CommitResult -} - -type CommitResult struct { - Signed_header CommitSignedHeader -} - -type CommitSignedHeader struct { - Header CommitHeader - Commit Commits -} - -type CommitHeader struct { - Chain_id string - Height string - Time time.Time - Num_txs string - Total_txs string - Proposer_address string -} - -type Commits struct { - Precommits []Precommits -} - -type Precommits struct { - Type int - Height string - Round string - Timestamp time.Time - Validator_address string - Validator_index string - Signature string -}