xrpl_api/api/
server_info.rs

1//! The server_info command asks the server for a human-readable version of
2//! various information about the rippled server being queried.
3//!
4//! <https://xrpl.org/server_info.html>
5
6use crate::Request;
7use serde::{Deserialize, Serialize};
8use std::collections::HashMap;
9
10#[derive(Default, Debug, Clone, Serialize)]
11pub struct ServerInfoRequest {}
12
13impl Request for ServerInfoRequest {
14    type Response = ServerInfoResponse;
15
16    fn method(&self) -> String {
17        "server_info".to_owned()
18    }
19}
20
21impl ServerInfoRequest {
22    pub fn new() -> Self {
23        Self::default()
24    }
25}
26
27/// Information about the time the server spends in server state. This can be
28/// useful for tracking the long-term health of your server's connectivity to
29/// the network.
30#[derive(Debug, Deserialize)]
31pub struct StateAccountingInfo {
32    /// The number of microseconds the server has spent in this state.
33    /// (This is updated whenever the server transitions into another state.)
34    pub duration_us: String,
35    /// The number of times the server has changed into this state.
36    pub transitions: String,
37}
38
39#[derive(Debug, Deserialize)]
40pub struct SIValidatedLedger {
41    pub seq: u32,
42    pub base_fee_xrp: f64,
43}
44
45#[derive(Debug, Deserialize)]
46pub struct ServerInfo {
47    pub amendment_blocked: Option<bool>,
48    pub build_version: Option<String>,
49    pub peers: Option<u32>,
50    pub hostid: Option<String>,
51    /// <https://xrpl.org/rippled-server-states.html>
52    pub server_state: Option<String>,
53    pub state_accounting: Option<HashMap<String, StateAccountingInfo>>,
54    pub time: Option<String>,
55    pub uptime: Option<u32>,
56    pub validated_ledger: SIValidatedLedger,
57    // #TODO add more fields
58}
59
60#[derive(Debug, Deserialize)]
61pub struct ServerInfoResponse {
62    pub info: ServerInfo,
63}