From ec10ba9a91ef7fe66c0a1122b9d7bfbed8658b11 Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 6 Jun 2024 20:45:43 +0200 Subject: [PATCH 1/7] revert removed telemetry handlers on 8123 port --- .../chains/bitcoin/observer/observer.go | 2 + zetaclient/chains/evm/observer/observer.go | 1 + zetaclient/metrics/telemetry.go | 114 ++++++++++++++++-- zetaclient/orchestrator/orchestrator.go | 1 + 4 files changed, 110 insertions(+), 8 deletions(-) diff --git a/zetaclient/chains/bitcoin/observer/observer.go b/zetaclient/chains/bitcoin/observer/observer.go index 91f0d695f4..55691f0b43 100644 --- a/zetaclient/chains/bitcoin/observer/observer.go +++ b/zetaclient/chains/bitcoin/observer/observer.go @@ -356,6 +356,7 @@ func (ob *Observer) GetLastBlockHeight() int64 { func (ob *Observer) SetLastBlockHeightScanned(height int64) { atomic.StoreInt64(&ob.lastBlockScanned, height) + ob.ts.SetLastScannedBlockNumber((ob.chain.ChainId), uint64(height)) metrics.LastScannedBlockNumber.WithLabelValues(ob.chain.ChainName.String()).Set(float64(height)) } @@ -594,6 +595,7 @@ func (ob *Observer) FetchUTXOS() error { } ob.Mu.Lock() + ob.ts.SetNumberOfUTXOs(len(utxosFiltered)) metrics.NumberOfUTXO.Set(float64(len(utxosFiltered))) ob.utxos = utxosFiltered ob.Mu.Unlock() diff --git a/zetaclient/chains/evm/observer/observer.go b/zetaclient/chains/evm/observer/observer.go index 4a38a62d12..3f2ff1edb6 100644 --- a/zetaclient/chains/evm/observer/observer.go +++ b/zetaclient/chains/evm/observer/observer.go @@ -422,6 +422,7 @@ func (ob *Observer) CheckTxInclusion(tx *ethtypes.Transaction, receipt *ethtypes // SetLastBlockHeightScanned set last block height scanned (not necessarily caught up with external block; could be slow/paused) func (ob *Observer) SetLastBlockHeightScanned(height uint64) { atomic.StoreUint64(&ob.lastBlockScanned, height) + ob.ts.SetLastScannedBlockNumber(ob.chain.ChainId, height) metrics.LastScannedBlockNumber.WithLabelValues(ob.chain.ChainName.String()).Set(float64(height)) } diff --git a/zetaclient/metrics/telemetry.go b/zetaclient/metrics/telemetry.go index bdedbd9c50..1bb8c31208 100644 --- a/zetaclient/metrics/telemetry.go +++ b/zetaclient/metrics/telemetry.go @@ -2,6 +2,7 @@ package metrics import ( "context" + "encoding/json" "errors" "fmt" "net/http" @@ -11,23 +12,31 @@ import ( "github.com/gorilla/mux" "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "github.com/zeta-chain/zetacore/pkg/constant" + "github.com/zeta-chain/zetacore/zetaclient/types" ) // TelemetryServer provide http endpoint for Tss server type TelemetryServer struct { - logger zerolog.Logger - s *http.Server - p2pid string - mu sync.Mutex - ipAddress string - HotKeyBurnRate *BurnRate + logger zerolog.Logger + s *http.Server + p2pid string + lastScannedBlockNumber map[int64]uint64 // chainid => block number + lastCoreBlockNumber int64 + mu sync.Mutex + lastStartTimestamp time.Time + status types.Status + ipAddress string + HotKeyBurnRate *BurnRate } // NewTelemetryServer should only listen to the loopback func NewTelemetryServer() *TelemetryServer { hs := &TelemetryServer{ - logger: log.With().Str("module", "http").Logger(), - HotKeyBurnRate: NewBurnRate(100), + logger: log.With().Str("module", "http").Logger(), + lastScannedBlockNumber: make(map[int64]uint64), + lastStartTimestamp: time.Now(), + HotKeyBurnRate: NewBurnRate(100), } s := &http.Server{ Addr: ":8123", @@ -67,6 +76,42 @@ func (t *TelemetryServer) GetIPAddress() string { return t.ipAddress } +func (t *TelemetryServer) GetLastStartTimestamp() time.Time { + t.mu.Lock() + defer t.mu.Unlock() + return t.lastStartTimestamp +} + +func (t *TelemetryServer) SetLastScannedBlockNumber(chainID int64, blockNumber uint64) { + t.mu.Lock() + t.lastScannedBlockNumber[chainID] = blockNumber + t.mu.Unlock() +} + +func (t *TelemetryServer) GetLastScannedBlockNumber(chainID int64) uint64 { + t.mu.Lock() + defer t.mu.Unlock() + return t.lastScannedBlockNumber[chainID] +} + +func (t *TelemetryServer) SetCoreBlockNumber(blockNumber int64) { + t.mu.Lock() + t.lastCoreBlockNumber = blockNumber + t.mu.Unlock() +} + +func (t *TelemetryServer) GetCoreBlockNumber() int64 { + t.mu.Lock() + defer t.mu.Unlock() + return t.lastCoreBlockNumber +} + +func (t *TelemetryServer) SetNumberOfUTXOs(numberOfUTXOs int) { + t.mu.Lock() + t.status.BTCNumberOfUTXOs = numberOfUTXOs + t.mu.Unlock() +} + // AddFeeEntry adds fee entry func (t *TelemetryServer) AddFeeEntry(block int64, amount int64) { t.mu.Lock() @@ -82,6 +127,11 @@ func (t *TelemetryServer) Handlers() http.Handler { router := mux.NewRouter() router.Handle("/ping", http.HandlerFunc(t.pingHandler)).Methods(http.MethodGet) router.Handle("/p2p", http.HandlerFunc(t.p2pHandler)).Methods(http.MethodGet) + router.Handle("/version", http.HandlerFunc(t.versionHandler)).Methods(http.MethodGet) + router.Handle("/lastscannedblock", http.HandlerFunc(t.lastScannedBlockHandler)).Methods(http.MethodGet) + 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("/ip", http.HandlerFunc(t.ipHandler)).Methods(http.MethodGet) router.Handle("/hotkeyburnrate", http.HandlerFunc(t.hotKeyFeeBurnRate)).Methods(http.MethodGet) @@ -131,6 +181,54 @@ func (t *TelemetryServer) ipHandler(w http.ResponseWriter, _ *http.Request) { fmt.Fprintf(w, "%s", t.ipAddress) } +func (t *TelemetryServer) lastScannedBlockHandler(w http.ResponseWriter, _ *http.Request) { + //w.WriteHeader(http.StatusOK) + w.Header().Set("Content-Type", "application/json") + + t.mu.Lock() + defer t.mu.Unlock() + // Convert map to JSON + jsonBytes, err := json.Marshal(t.lastScannedBlockNumber) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + _, err = w.Write(jsonBytes) + if err != nil { + t.logger.Error().Err(err).Msg("Failed to write response") + } +} + +func (t *TelemetryServer) lastCoreBlockHandler(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + t.mu.Lock() + defer t.mu.Unlock() + fmt.Fprintf(w, "%d", t.lastCoreBlockNumber) +} + +func (t *TelemetryServer) statusHandler(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + t.mu.Lock() + defer t.mu.Unlock() + s, err := json.MarshalIndent(t.status, "", "\t") + if err != nil { + t.logger.Error().Err(err).Msg("Failed to marshal status") + } + fmt.Fprintf(w, "%s", s) +} + +func (t *TelemetryServer) versionHandler(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, "%s", constant.Version) +} + +func (t *TelemetryServer) lastStartTimestampHandler(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + t.mu.Lock() + defer t.mu.Unlock() + fmt.Fprintf(w, "%s", t.lastStartTimestamp.Format(time.RFC3339)) +} + func (t *TelemetryServer) hotKeyFeeBurnRate(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) t.mu.Lock() diff --git a/zetaclient/orchestrator/orchestrator.go b/zetaclient/orchestrator/orchestrator.go index f9678301ff..1f9e99a9d4 100644 --- a/zetaclient/orchestrator/orchestrator.go +++ b/zetaclient/orchestrator/orchestrator.go @@ -325,6 +325,7 @@ func (oc *Orchestrator) StartCctxScheduler(appContext *context.AppContext) { // update last processed block number lastBlockNum = bn + oc.ts.SetCoreBlockNumber(lastBlockNum) metrics.LastCoreBlockNumber.Set(float64(lastBlockNum)) } } From 4a5192de7c7560a7dd26f722d82b56b9fe93ebff Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 6 Jun 2024 20:56:55 +0200 Subject: [PATCH 2/7] set related metrics in ts --- zetaclient/chains/bitcoin/observer/observer.go | 4 +--- zetaclient/chains/evm/observer/observer.go | 3 +-- zetaclient/metrics/telemetry.go | 16 ++++++++++------ zetaclient/orchestrator/orchestrator.go | 1 - 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/zetaclient/chains/bitcoin/observer/observer.go b/zetaclient/chains/bitcoin/observer/observer.go index 55691f0b43..c461c4f68e 100644 --- a/zetaclient/chains/bitcoin/observer/observer.go +++ b/zetaclient/chains/bitcoin/observer/observer.go @@ -356,8 +356,7 @@ func (ob *Observer) GetLastBlockHeight() int64 { func (ob *Observer) SetLastBlockHeightScanned(height int64) { atomic.StoreInt64(&ob.lastBlockScanned, height) - ob.ts.SetLastScannedBlockNumber((ob.chain.ChainId), uint64(height)) - metrics.LastScannedBlockNumber.WithLabelValues(ob.chain.ChainName.String()).Set(float64(height)) + ob.ts.SetLastScannedBlockNumber((ob.chain.ChainName), uint64(height)) } func (ob *Observer) GetLastBlockHeightScanned() int64 { @@ -596,7 +595,6 @@ func (ob *Observer) FetchUTXOS() error { ob.Mu.Lock() ob.ts.SetNumberOfUTXOs(len(utxosFiltered)) - metrics.NumberOfUTXO.Set(float64(len(utxosFiltered))) ob.utxos = utxosFiltered ob.Mu.Unlock() return nil diff --git a/zetaclient/chains/evm/observer/observer.go b/zetaclient/chains/evm/observer/observer.go index 3f2ff1edb6..85cce3d4c7 100644 --- a/zetaclient/chains/evm/observer/observer.go +++ b/zetaclient/chains/evm/observer/observer.go @@ -422,8 +422,7 @@ func (ob *Observer) CheckTxInclusion(tx *ethtypes.Transaction, receipt *ethtypes // SetLastBlockHeightScanned set last block height scanned (not necessarily caught up with external block; could be slow/paused) func (ob *Observer) SetLastBlockHeightScanned(height uint64) { atomic.StoreUint64(&ob.lastBlockScanned, height) - ob.ts.SetLastScannedBlockNumber(ob.chain.ChainId, height) - metrics.LastScannedBlockNumber.WithLabelValues(ob.chain.ChainName.String()).Set(float64(height)) + ob.ts.SetLastScannedBlockNumber(ob.chain.ChainName, height) } // GetLastBlockHeightScanned get last block height scanned (not necessarily caught up with external block; could be slow/paused) diff --git a/zetaclient/metrics/telemetry.go b/zetaclient/metrics/telemetry.go index 1bb8c31208..139a2e1974 100644 --- a/zetaclient/metrics/telemetry.go +++ b/zetaclient/metrics/telemetry.go @@ -12,6 +12,7 @@ import ( "github.com/gorilla/mux" "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/constant" "github.com/zeta-chain/zetacore/zetaclient/types" ) @@ -21,7 +22,7 @@ type TelemetryServer struct { logger zerolog.Logger s *http.Server p2pid string - lastScannedBlockNumber map[int64]uint64 // chainid => block number + lastScannedBlockNumber map[string]uint64 // chainName => block number lastCoreBlockNumber int64 mu sync.Mutex lastStartTimestamp time.Time @@ -34,7 +35,7 @@ type TelemetryServer struct { func NewTelemetryServer() *TelemetryServer { hs := &TelemetryServer{ logger: log.With().Str("module", "http").Logger(), - lastScannedBlockNumber: make(map[int64]uint64), + lastScannedBlockNumber: make(map[string]uint64), lastStartTimestamp: time.Now(), HotKeyBurnRate: NewBurnRate(100), } @@ -82,21 +83,23 @@ func (t *TelemetryServer) GetLastStartTimestamp() time.Time { return t.lastStartTimestamp } -func (t *TelemetryServer) SetLastScannedBlockNumber(chainID int64, blockNumber uint64) { +func (t *TelemetryServer) SetLastScannedBlockNumber(chainName chains.ChainName, blockNumber uint64) { t.mu.Lock() - t.lastScannedBlockNumber[chainID] = blockNumber + t.lastScannedBlockNumber[chainName.String()] = blockNumber + LastScannedBlockNumber.WithLabelValues(chainName.String()).Set(float64(blockNumber)) t.mu.Unlock() } -func (t *TelemetryServer) GetLastScannedBlockNumber(chainID int64) uint64 { +func (t *TelemetryServer) GetLastScannedBlockNumber(chainName chains.ChainName) uint64 { t.mu.Lock() defer t.mu.Unlock() - return t.lastScannedBlockNumber[chainID] + return t.lastScannedBlockNumber[chainName.String()] } func (t *TelemetryServer) SetCoreBlockNumber(blockNumber int64) { t.mu.Lock() t.lastCoreBlockNumber = blockNumber + LastCoreBlockNumber.Set(float64(blockNumber)) t.mu.Unlock() } @@ -109,6 +112,7 @@ func (t *TelemetryServer) GetCoreBlockNumber() int64 { func (t *TelemetryServer) SetNumberOfUTXOs(numberOfUTXOs int) { t.mu.Lock() t.status.BTCNumberOfUTXOs = numberOfUTXOs + NumberOfUTXO.Set(float64(numberOfUTXOs)) t.mu.Unlock() } diff --git a/zetaclient/orchestrator/orchestrator.go b/zetaclient/orchestrator/orchestrator.go index 1f9e99a9d4..a94b1cdd73 100644 --- a/zetaclient/orchestrator/orchestrator.go +++ b/zetaclient/orchestrator/orchestrator.go @@ -326,7 +326,6 @@ func (oc *Orchestrator) StartCctxScheduler(appContext *context.AppContext) { // update last processed block number lastBlockNum = bn oc.ts.SetCoreBlockNumber(lastBlockNum) - metrics.LastCoreBlockNumber.Set(float64(lastBlockNum)) } } } From 37b9ab9d93d8d763524e5683fecc9a5d7d023b3d Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 6 Jun 2024 21:00:10 +0200 Subject: [PATCH 3/7] changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 598ce8dd6a..e2a0db4753 100644 --- a/changelog.md +++ b/changelog.md @@ -25,6 +25,7 @@ * [2305](https://github.com/zeta-chain/node/pull/2305) - add new messages `MsgAddAuthorization` and `MsgRemoveAuthorization` that can be used to update the authorization list * [2313](https://github.com/zeta-chain/node/pull/2313) - add `CheckAuthorization` function to replace the `IsAuthorized` function. The new function uses the authorization list to verify the signer's authorization. * [2312](https://github.com/zeta-chain/node/pull/2312) - add queries `ShowAuthorization` and `ListAuthorizations` +* [2325](https://github.com/zeta-chain/node/pull/2325) - revert telemetry server changes ### Refactor From 302288f089a8d1cf221957da0fca8694bb0a676d Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 6 Jun 2024 21:27:00 +0200 Subject: [PATCH 4/7] make generate --- zetaclient/metrics/telemetry.go | 1 + 1 file changed, 1 insertion(+) diff --git a/zetaclient/metrics/telemetry.go b/zetaclient/metrics/telemetry.go index 139a2e1974..937bb5885f 100644 --- a/zetaclient/metrics/telemetry.go +++ b/zetaclient/metrics/telemetry.go @@ -12,6 +12,7 @@ import ( "github.com/gorilla/mux" "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/constant" "github.com/zeta-chain/zetacore/zetaclient/types" From cca558918eb4238be8c5c3c427faf09c0ce5f98c Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 6 Jun 2024 21:35:46 +0200 Subject: [PATCH 5/7] lint --- zetaclient/chains/bitcoin/observer/observer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/zetaclient/chains/bitcoin/observer/observer.go b/zetaclient/chains/bitcoin/observer/observer.go index c461c4f68e..963cce6336 100644 --- a/zetaclient/chains/bitcoin/observer/observer.go +++ b/zetaclient/chains/bitcoin/observer/observer.go @@ -356,6 +356,7 @@ func (ob *Observer) GetLastBlockHeight() int64 { func (ob *Observer) SetLastBlockHeightScanned(height int64) { atomic.StoreInt64(&ob.lastBlockScanned, height) + // #nosec G701 checked as positive ob.ts.SetLastScannedBlockNumber((ob.chain.ChainName), uint64(height)) } From 93110fd1480b1760ae7b30e4972f7a7e22e924f6 Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 6 Jun 2024 23:03:00 +0200 Subject: [PATCH 6/7] PR comments --- .../chains/bitcoin/observer/observer.go | 2 +- zetaclient/chains/evm/observer/observer.go | 2 +- zetaclient/metrics/telemetry.go | 25 ++++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/zetaclient/chains/bitcoin/observer/observer.go b/zetaclient/chains/bitcoin/observer/observer.go index 963cce6336..f4cad393c8 100644 --- a/zetaclient/chains/bitcoin/observer/observer.go +++ b/zetaclient/chains/bitcoin/observer/observer.go @@ -357,7 +357,7 @@ func (ob *Observer) GetLastBlockHeight() int64 { func (ob *Observer) SetLastBlockHeightScanned(height int64) { atomic.StoreInt64(&ob.lastBlockScanned, height) // #nosec G701 checked as positive - ob.ts.SetLastScannedBlockNumber((ob.chain.ChainName), uint64(height)) + ob.ts.SetLastScannedBlockNumber(ob.chain, uint64(height)) } func (ob *Observer) GetLastBlockHeightScanned() int64 { diff --git a/zetaclient/chains/evm/observer/observer.go b/zetaclient/chains/evm/observer/observer.go index 85cce3d4c7..795aa3b13b 100644 --- a/zetaclient/chains/evm/observer/observer.go +++ b/zetaclient/chains/evm/observer/observer.go @@ -422,7 +422,7 @@ func (ob *Observer) CheckTxInclusion(tx *ethtypes.Transaction, receipt *ethtypes // SetLastBlockHeightScanned set last block height scanned (not necessarily caught up with external block; could be slow/paused) func (ob *Observer) SetLastBlockHeightScanned(height uint64) { atomic.StoreUint64(&ob.lastBlockScanned, height) - ob.ts.SetLastScannedBlockNumber(ob.chain.ChainName, height) + ob.ts.SetLastScannedBlockNumber(ob.chain, height) } // GetLastBlockHeightScanned get last block height scanned (not necessarily caught up with external block; could be slow/paused) diff --git a/zetaclient/metrics/telemetry.go b/zetaclient/metrics/telemetry.go index 937bb5885f..db2ebbd514 100644 --- a/zetaclient/metrics/telemetry.go +++ b/zetaclient/metrics/telemetry.go @@ -18,12 +18,12 @@ import ( "github.com/zeta-chain/zetacore/zetaclient/types" ) -// TelemetryServer provide http endpoint for Tss server +// TelemetryServer provides http endpoint for Tss server type TelemetryServer struct { logger zerolog.Logger s *http.Server p2pid string - lastScannedBlockNumber map[string]uint64 // chainName => block number + lastScannedBlockNumber map[int64]uint64 // chainId => block number lastCoreBlockNumber int64 mu sync.Mutex lastStartTimestamp time.Time @@ -36,7 +36,7 @@ type TelemetryServer struct { func NewTelemetryServer() *TelemetryServer { hs := &TelemetryServer{ logger: log.With().Str("module", "http").Logger(), - lastScannedBlockNumber: make(map[string]uint64), + lastScannedBlockNumber: make(map[int64]uint64), lastStartTimestamp: time.Now(), HotKeyBurnRate: NewBurnRate(100), } @@ -78,25 +78,29 @@ func (t *TelemetryServer) GetIPAddress() string { return t.ipAddress } +// GetLastStartTimestamp returns last start timestamp func (t *TelemetryServer) GetLastStartTimestamp() time.Time { t.mu.Lock() defer t.mu.Unlock() return t.lastStartTimestamp } -func (t *TelemetryServer) SetLastScannedBlockNumber(chainName chains.ChainName, blockNumber uint64) { +// SetLastScannedBlockNumber last scanned block number for chain in telemetry and metrics +func (t *TelemetryServer) SetLastScannedBlockNumber(chain chains.Chain, blockNumber uint64) { t.mu.Lock() - t.lastScannedBlockNumber[chainName.String()] = blockNumber - LastScannedBlockNumber.WithLabelValues(chainName.String()).Set(float64(blockNumber)) + t.lastScannedBlockNumber[chain.ChainId] = blockNumber + LastScannedBlockNumber.WithLabelValues(chain.ChainName.String()).Set(float64(blockNumber)) t.mu.Unlock() } -func (t *TelemetryServer) GetLastScannedBlockNumber(chainName chains.ChainName) uint64 { +// GetLastScannedBlockNumber returns last scanned block number for chain +func (t *TelemetryServer) GetLastScannedBlockNumber(chainId int64) uint64 { t.mu.Lock() defer t.mu.Unlock() - return t.lastScannedBlockNumber[chainName.String()] + return t.lastScannedBlockNumber[chainId] } +// SetCoreBlockNumber sets core block number in telemetry and metrics func (t *TelemetryServer) SetCoreBlockNumber(blockNumber int64) { t.mu.Lock() t.lastCoreBlockNumber = blockNumber @@ -104,12 +108,14 @@ func (t *TelemetryServer) SetCoreBlockNumber(blockNumber int64) { t.mu.Unlock() } +// GetCoreBlockNumber returns core block number func (t *TelemetryServer) GetCoreBlockNumber() int64 { t.mu.Lock() defer t.mu.Unlock() return t.lastCoreBlockNumber } +// SetNumberOfUTXOs sets number of UTXOs in telemetry and metrics func (t *TelemetryServer) SetNumberOfUTXOs(numberOfUTXOs int) { t.mu.Lock() t.status.BTCNumberOfUTXOs = numberOfUTXOs @@ -145,6 +151,7 @@ func (t *TelemetryServer) Handlers() http.Handler { return router } +// Start starts telemetry server func (t *TelemetryServer) Start() error { if t.s == nil { return errors.New("invalid http server instance") @@ -158,6 +165,7 @@ func (t *TelemetryServer) Start() error { return nil } +// Stop stops telemetry server func (t *TelemetryServer) Stop() error { c, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() @@ -187,7 +195,6 @@ func (t *TelemetryServer) ipHandler(w http.ResponseWriter, _ *http.Request) { } func (t *TelemetryServer) lastScannedBlockHandler(w http.ResponseWriter, _ *http.Request) { - //w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "application/json") t.mu.Lock() From 2ef3b482b7e1b0f48ba30898d310d48c1f8c4a0c Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 6 Jun 2024 23:09:38 +0200 Subject: [PATCH 7/7] lint --- zetaclient/metrics/telemetry.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zetaclient/metrics/telemetry.go b/zetaclient/metrics/telemetry.go index db2ebbd514..f49c1bf7b1 100644 --- a/zetaclient/metrics/telemetry.go +++ b/zetaclient/metrics/telemetry.go @@ -23,7 +23,7 @@ type TelemetryServer struct { logger zerolog.Logger s *http.Server p2pid string - lastScannedBlockNumber map[int64]uint64 // chainId => block number + lastScannedBlockNumber map[int64]uint64 // chainID => block number lastCoreBlockNumber int64 mu sync.Mutex lastStartTimestamp time.Time @@ -94,10 +94,10 @@ func (t *TelemetryServer) SetLastScannedBlockNumber(chain chains.Chain, blockNum } // GetLastScannedBlockNumber returns last scanned block number for chain -func (t *TelemetryServer) GetLastScannedBlockNumber(chainId int64) uint64 { +func (t *TelemetryServer) GetLastScannedBlockNumber(chainID int64) uint64 { t.mu.Lock() defer t.mu.Unlock() - return t.lastScannedBlockNumber[chainId] + return t.lastScannedBlockNumber[chainID] } // SetCoreBlockNumber sets core block number in telemetry and metrics