Merge pull request #5 from benzcash/ben/revert-add-chaintips

Revert "Addded metrics for getchaintips"
This commit is contained in:
Ben Wilson 2019-12-04 08:32:50 -05:00 committed by GitHub
commit 4a1bf25722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 46 deletions

View File

@ -27,12 +27,6 @@ var (
[]string{
"type",
})
zcashdChainTips = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "zcash_chain_tip",
Help: "Return information about all known tips in the block tree, including the main chain as well as orphaned branches."},
[]string{"height", "hash", "branchlen", "status"},
)
)
// ZCASH_PEERS = Gauge("zcash_peers", "Number of peers")
@ -67,5 +61,4 @@ func init() {
prometheus.MustRegister(zcashdMemPoolBytes)
prometheus.MustRegister(zcashdMemPoolUsage)
prometheus.MustRegister(zcashdWalletBalance)
prometheus.MustRegister(zcashdChainTips)
}

28
main.go
View File

@ -55,7 +55,6 @@ func main() {
go getBlockchainInfo()
go getMemPoolInfo()
go getWalletInfo()
go getChainTips()
log.Infoln("Listening on", *listenAddress)
if err := http.ListenAndServe(*listenAddress, nil); err != nil {
log.Fatal(err)
@ -134,30 +133,3 @@ func getWalletInfo() {
}
}
func getChainTips() {
basicAuth := base64.StdEncoding.EncodeToString([]byte(*rpcUser + ":" + *rpcPassword))
rpcClient := jsonrpc.NewClientWithOpts("http://"+*rpcHost+":"+*rpcPort,
&jsonrpc.RPCClientOpts{
CustomHeaders: map[string]string{
"Authorization": "Basic " + basicAuth,
}})
var chaintips *GetChainTips
for {
if err := rpcClient.CallFor(&chaintips, "getchaintips"); err != nil {
log.Warnln("Error calling getchaintips", err)
} else {
for _, ct := range *chaintips {
log.Infoln("Got chaintip: ", ct.Height)
zcashdChainTips.WithLabelValues(
strconv.FormatFloat(ct.Height, 'f', 2, 64),
ct.Hash,
strconv.FormatFloat(ct.Branchlen, 'f', 2, 64),
ct.Status).Set(ct.Height)
}
}
time.Sleep(time.Duration(30) * time.Second)
}
}

11
rpc.go
View File

@ -25,14 +25,3 @@ type ZGetTotalBalance struct {
Private string `json:"private"`
Total string `json:"total"`
}
// GetChainTips Return information about all known tips in the block tree, including the main chain as well as orphaned branches.
// https://zcash-rpc.github.io/getchaintips.html
type GetChainTips []ChainTip
type ChainTip struct {
Height float64 `json:"height"`
Hash string `json:"hash"`
Branchlen float64 `json:"branchlen"`
Status string `json:"status"`
}