Skip to content

Commit

Permalink
Merge branch 'develop' into docs/status-diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev authored Jul 6, 2023
2 parents ac6b36c + 993d0a6 commit 7eecf78
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ func (ob *BitcoinChainClient) fetchUTXOS() error {
filtered = append(filtered, utxo)
}
}
ob.ts.SetNumberOfUTXOs(len(utxos), len(filtered))
// sort by value
sort.Slice(filtered, func(i, j int) bool {
return filtered[i].Amount < filtered[j].Amount
Expand Down
16 changes: 11 additions & 5 deletions zetaclient/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"github.com/zeta-chain/zetacore/common"
"net/http"
"net/http/pprof"
"sync"
"time"

Expand Down Expand Up @@ -102,6 +101,13 @@ func (t *TelemetryServer) GetNextNonce() int {
return t.status.BTCNextNonce
}

func (t *TelemetryServer) SetNumberOfUTXOs(numberOfUTXOs, numberOfFilteredUTXOs int) {
t.mu.Lock()
t.status.BTCNumberOfUTXOs = numberOfUTXOs
t.status.BTCNumberOfFilteredUTXOs = numberOfFilteredUTXOs
t.mu.Unlock()
}

// NewHandler registers the API routes and returns a new HTTP handler
func (t *TelemetryServer) Handlers() http.Handler {
router := mux.NewRouter()
Expand All @@ -112,10 +118,10 @@ func (t *TelemetryServer) Handlers() http.Handler {
router.Handle("/laststarttimestamp", http.HandlerFunc(t.lastStartTimestampHandler)).Methods(http.MethodGet)
router.Handle("/lastcoreblock", http.HandlerFunc(t.lastCoreBlockHandler)).Methods(http.MethodGet)
router.Handle("/status", http.HandlerFunc(t.statusHandler)).Methods(http.MethodGet)
router.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
router.Handle("/debug/pprof/heap", pprof.Handler("heap"))
router.HandleFunc("/debug/pprof/", pprof.Index)
router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
// router.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
// router.Handle("/debug/pprof/heap", pprof.Handler("heap"))
// router.HandleFunc("/debug/pprof/", pprof.Index)
// router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)

//router.Handle("/pending", http.HandlerFunc(t.pendingHandler)).Methods(http.MethodGet)
router.Use(logMiddleware())
Expand Down
4 changes: 3 additions & 1 deletion zetaclient/types/telemetry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ package types

// Status type for telemetry. More fields can be added as needed
type Status struct {
BTCNextNonce int `json:"btc_next_nonce"`
BTCNextNonce int `json:"btc_next_nonce"`
BTCNumberOfUTXOs int `json:"btc_number_of_utxos"`
BTCNumberOfFilteredUTXOs int `json:"btc_number_of_filtered_utxos"`
}

0 comments on commit 7eecf78

Please sign in to comment.