Merge pull request #5 from benzcash/ben/revert-add-chaintips
Revert "Addded metrics for getchaintips"
This commit is contained in:
commit
4a1bf25722
|
@ -27,12 +27,6 @@ var (
|
||||||
[]string{
|
[]string{
|
||||||
"type",
|
"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")
|
// ZCASH_PEERS = Gauge("zcash_peers", "Number of peers")
|
||||||
|
@ -67,5 +61,4 @@ func init() {
|
||||||
prometheus.MustRegister(zcashdMemPoolBytes)
|
prometheus.MustRegister(zcashdMemPoolBytes)
|
||||||
prometheus.MustRegister(zcashdMemPoolUsage)
|
prometheus.MustRegister(zcashdMemPoolUsage)
|
||||||
prometheus.MustRegister(zcashdWalletBalance)
|
prometheus.MustRegister(zcashdWalletBalance)
|
||||||
prometheus.MustRegister(zcashdChainTips)
|
|
||||||
}
|
}
|
||||||
|
|
28
main.go
28
main.go
|
@ -55,7 +55,6 @@ func main() {
|
||||||
go getBlockchainInfo()
|
go getBlockchainInfo()
|
||||||
go getMemPoolInfo()
|
go getMemPoolInfo()
|
||||||
go getWalletInfo()
|
go getWalletInfo()
|
||||||
go getChainTips()
|
|
||||||
log.Infoln("Listening on", *listenAddress)
|
log.Infoln("Listening on", *listenAddress)
|
||||||
if err := http.ListenAndServe(*listenAddress, nil); err != nil {
|
if err := http.ListenAndServe(*listenAddress, nil); err != nil {
|
||||||
log.Fatal(err)
|
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
11
rpc.go
|
@ -25,14 +25,3 @@ type ZGetTotalBalance struct {
|
||||||
Private string `json:"private"`
|
Private string `json:"private"`
|
||||||
Total string `json:"total"`
|
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"`
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue