@@ -24,7 +24,7 @@ use crate::chain::{BlockHeader, Network, OutPoint, Transaction, TxOut, Value};
24
24
use crate :: config:: Config ;
25
25
use crate :: daemon:: Daemon ;
26
26
use crate :: errors:: * ;
27
- use crate :: metrics:: { HistogramOpts , HistogramTimer , HistogramVec , Metrics } ;
27
+ use crate :: metrics:: { Gauge , HistogramOpts , HistogramTimer , HistogramVec , MetricOpts , Metrics } ;
28
28
use crate :: util:: {
29
29
full_hash, has_prevout, is_spendable, script_to_address, BlockHeaderMeta , BlockId , BlockMeta ,
30
30
BlockStatus , Bytes , HeaderEntry , HeaderList ,
@@ -164,6 +164,7 @@ pub struct Indexer {
164
164
from : FetchFrom ,
165
165
iconfig : IndexerConfig ,
166
166
duration : HistogramVec ,
167
+ tip_metric : Gauge ,
167
168
}
168
169
169
170
struct IndexerConfig {
@@ -208,6 +209,7 @@ impl Indexer {
208
209
HistogramOpts :: new ( "index_duration" , "Index update duration (in seconds)" ) ,
209
210
& [ "step" ] ,
210
211
) ,
212
+ tip_metric : metrics. gauge ( MetricOpts :: new ( "tip_height" , "Current chain tip height" ) ) ,
211
213
}
212
214
}
213
215
@@ -296,6 +298,8 @@ impl Indexer {
296
298
self . from = FetchFrom :: Bitcoind ;
297
299
}
298
300
301
+ self . tip_metric . set ( headers. len ( ) as i64 - 1 ) ;
302
+
299
303
Ok ( tip)
300
304
}
301
305
0 commit comments