@@ -68,6 +68,7 @@ impl HandleRequest for RuskNode {
68
68
( "blocks" , _, "gas-price" ) => true ,
69
69
( "blobs" , Some ( _) , "commitment" ) => true ,
70
70
( "blobs" , Some ( _) , "hash" ) => true ,
71
+ ( "stats" , _, "tx_count" ) => true ,
71
72
72
73
_ => false ,
73
74
}
@@ -120,10 +121,14 @@ impl HandleRequest for RuskNode {
120
121
. map_err ( |_| anyhow:: anyhow!( "Invalid hash length" ) ) ?;
121
122
self . blob_by_hash ( & hash, request. is_json ( ) ) . await
122
123
}
124
+
125
+ ( "stats" , _, "tx_count" ) => self . get_tx_count ( ) . await ,
126
+
123
127
_ => anyhow:: bail!( "Unsupported" ) ,
124
128
}
125
129
}
126
130
}
131
+
127
132
impl RuskNode {
128
133
async fn handle_gql (
129
134
& self ,
@@ -384,6 +389,34 @@ impl RuskNode {
384
389
"next_nonce" : next_nonce,
385
390
} ) ) )
386
391
}
392
+
393
+ /// Returns the total number of finalized transactions observed in the
394
+ /// archive, split into `public`, `shielded` and `total. The response is
395
+ /// a JSON object:
396
+ /// ```json
397
+ /// { "public": 123, "shielded": 456, "total": 579 }
398
+ /// ```
399
+ ///
400
+ /// # Errors
401
+ /// Returns an error if the archive feature is not enabled.
402
+ async fn get_tx_count ( & self ) -> anyhow:: Result < ResponseData > {
403
+ #[ cfg( feature = "archive" ) ]
404
+ {
405
+ let ( moonlight, phoenix) = self . archive ( ) . fetch_tx_count ( ) . await ?;
406
+ let total = moonlight + phoenix;
407
+ let body = serde_json:: json!( {
408
+ "public" : moonlight,
409
+ "shielded" : phoenix,
410
+ "total" : total
411
+ } ) ;
412
+ Ok ( ResponseData :: new ( body) )
413
+ }
414
+
415
+ #[ cfg( not( feature = "archive" ) ) ]
416
+ {
417
+ anyhow:: bail!( "The archive feature is required for this endpoint." ) ;
418
+ }
419
+ }
387
420
}
388
421
389
422
async fn load_tip < DB : database:: DB > (
0 commit comments