@@ -33,6 +33,11 @@ func NewVochainInfo(node *vochain.BaseApplication) *VochainInfo {
3333}
3434
3535func (vi * VochainInfo ) updateCounters () {
36+ if ! vi .vnode .IsSynced () {
37+ blocksyncHeight .Set (uint64 (vi .vnode .Height ()))
38+ blocksyncBPM .Set (uint64 (vi .BlocksLastMinute ()))
39+ return
40+ }
3641 height .Set (uint64 (vi .vnode .Height ()))
3742
3843 pc , err := vi .vnode .State .CountProcesses (true )
@@ -62,7 +67,6 @@ func (vi *VochainInfo) updateCounters() {
6267 voteCacheSize .Set (uint64 (vi .vnode .State .CacheSize ()))
6368 mempoolSize .Set (uint64 (vi .vnode .MempoolSize ()))
6469 blockPeriodMinute .Set (uint64 (vi .BlockTimes ()[0 ].Milliseconds ()))
65- blocksSyncLastMinute .Set (uint64 (vi .BlocksLastMinute ()))
6670}
6771
6872// Height returns the current number of blocks of the blockchain.
@@ -259,7 +263,11 @@ func (vi *VochainInfo) Start(sleepSecs uint64) {
259263 panic ("sleepSecs cannot be zero" )
260264 }
261265 log .Infof ("starting vochain info service every %d seconds" , sleepSecs )
262- metrics .NewGauge ("vochain_tokens_burned" ,
266+
267+ metrics .UnregisterSet (viMetrics )
268+ metrics .RegisterSet (blocksyncMetrics )
269+
270+ viMetrics .NewGauge ("vochain_tokens_burned" ,
263271 func () float64 { return float64 (vi .TokensBurned ()) })
264272
265273 var duration time.Duration
@@ -270,6 +278,9 @@ func (vi *VochainInfo) Start(sleepSecs uint64) {
270278 duration = time .Second * time .Duration (sleepSecs )
271279 for {
272280 select {
281+ case <- vi .vnode .WaitUntilSynced ():
282+ metrics .RegisterSet (viMetrics )
283+ metrics .UnregisterSet (blocksyncMetrics )
273284 case <- time .After (duration ):
274285 vi .updateCounters ()
275286 currentHeight = uint64 (vi .vnode .Height ())
0 commit comments