@@ -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" , _, "account_count" ) => true ,
71
72
( "stats" , _, "tx_count" ) => true ,
72
73
73
74
_ => false ,
@@ -122,6 +123,7 @@ impl HandleRequest for RuskNode {
122
123
self . blob_by_hash ( & hash, request. is_json ( ) ) . await
123
124
}
124
125
126
+ ( "stats" , _, "account_count" ) => self . get_account_count ( ) . await ,
125
127
( "stats" , _, "tx_count" ) => self . get_tx_count ( ) . await ,
126
128
127
129
_ => anyhow:: bail!( "Unsupported" ) ,
@@ -390,7 +392,29 @@ impl RuskNode {
390
392
} ) ) )
391
393
}
392
394
393
- /// Returns the total number of finalized transactions observed in the
395
+ /// Returns the total number of active public accounts recorded in the
396
+ /// archive node. The response is a JSON object:
397
+ /// ```json
398
+ /// { "public_accounts": 12345 }
399
+ /// ```
400
+ ///
401
+ /// # Errors
402
+ /// Returns an error if the archive feature is not enabled.
403
+ async fn get_account_count ( & self ) -> anyhow:: Result < ResponseData > {
404
+ #[ cfg( feature = "archive" ) ]
405
+ {
406
+ let count = self . archive ( ) . fetch_active_accounts ( ) . await ?;
407
+ let body = serde_json:: json!( { "public_accounts" : count } ) ;
408
+ Ok ( ResponseData :: new ( body) )
409
+ }
410
+
411
+ #[ cfg( not( feature = "archive" ) ) ]
412
+ {
413
+ anyhow:: bail!( "The archive feature is required for this endpoint." ) ;
414
+ }
415
+ }
416
+
417
+ /// Returns the total number of finalized transactions observed in the
394
418
/// archive, split into `public`, `shielded` and `total. The response is
395
419
/// a JSON object:
396
420
/// ```json
0 commit comments