Skip to main content

hashiverse_server_lib/server/stats/
environment_stats.rs

1use crate::environment::environment::Environment;
2
3/// Build the `environment` subtree: counts and sizes of persisted state.
4///
5/// Counts come from the underlying store (cheap — fjall keyspace length, no
6/// scan). `post_bundle_total_bytes` comes from the running counter the quota
7/// system already maintains, so this is also O(1).
8pub fn environment_stats_subtree(environment: &Environment) -> serde_json::Value {
9    let post_bundle_count = environment.post_bundle_count().unwrap_or(0);
10    let post_bundle_feedback_count = environment.post_bundle_feedback_count().unwrap_or(0);
11    let post_bundle_total_bytes = environment.post_bundle_total_bytes();
12
13    serde_json::json!({
14        "post_bundle_count": post_bundle_count,
15        "post_bundle_feedback_count": post_bundle_feedback_count,
16        "post_bundle_total_bytes": post_bundle_total_bytes,
17    })
18}