@@ -24,7 +24,7 @@ use crate::chain::{BlockHeader, Network, OutPoint, Transaction, TxOut, Value};
2424use  crate :: config:: Config ; 
2525use  crate :: daemon:: Daemon ; 
2626use  crate :: errors:: * ; 
27- use  crate :: metrics:: { HistogramOpts ,  HistogramTimer ,  HistogramVec ,  Metrics } ; 
27+ use  crate :: metrics:: { Gauge ,   HistogramOpts ,  HistogramTimer ,  HistogramVec ,   MetricOpts ,  Metrics } ; 
2828use  crate :: util:: { 
2929    full_hash,  has_prevout,  is_spendable,  script_to_address,  BlockHeaderMeta ,  BlockId ,  BlockMeta , 
3030    BlockStatus ,  Bytes ,  HeaderEntry ,  HeaderList , 
@@ -164,6 +164,7 @@ pub struct Indexer {
164164    from :  FetchFrom , 
165165    iconfig :  IndexerConfig , 
166166    duration :  HistogramVec , 
167+     tip_metric :  Gauge , 
167168} 
168169
169170struct  IndexerConfig  { 
@@ -208,6 +209,7 @@ impl Indexer {
208209                HistogramOpts :: new ( "index_duration" ,  "Index update duration (in seconds)" ) , 
209210                & [ "step" ] , 
210211            ) , 
212+             tip_metric :  metrics. gauge ( MetricOpts :: new ( "tip_height" ,  "Current chain tip height" ) ) , 
211213        } 
212214    } 
213215
@@ -296,6 +298,8 @@ impl Indexer {
296298            self . from  = FetchFrom :: Bitcoind ; 
297299        } 
298300
301+         self . tip_metric . set ( headers. len ( )  as  i64  - 1 ) ; 
302+ 
299303        Ok ( tip) 
300304    } 
301305
0 commit comments