cometbft_rpc/endpoint/
status.rs

1//! `/status` endpoint JSON-RPC wrapper
2
3use cometbft::{block, node, validator, AppHash, Hash, Time};
4use serde::{Deserialize, Serialize};
5
6use crate::{dialect::Dialect, request::RequestMessage};
7
8/// Node status request
9#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
10pub struct Request;
11
12impl RequestMessage for Request {
13    fn method(&self) -> crate::Method {
14        crate::Method::Status
15    }
16}
17
18impl<S: Dialect> crate::Request<S> for Request {
19    type Response = Response;
20}
21
22impl<S: Dialect> crate::SimpleRequest<S> for Request {
23    type Output = Response;
24}
25
26/// Status responses
27#[derive(Clone, Debug, Deserialize, Serialize)]
28pub struct Response {
29    /// Node information
30    pub node_info: node::Info,
31
32    /// Sync information
33    pub sync_info: SyncInfo,
34
35    /// Validator information
36    pub validator_info: validator::Info,
37}
38
39impl crate::Response for Response {}
40
41/// Sync information
42#[derive(Clone, Debug, Deserialize, Serialize)]
43pub struct SyncInfo {
44    /// Earliest block hash
45    #[serde(with = "cometbft::serializers::hash")]
46    pub earliest_block_hash: Hash,
47
48    /// Earliest app hash
49    #[serde(with = "cometbft::serializers::apphash")]
50    pub earliest_app_hash: AppHash,
51
52    /// Earliest block height
53    pub earliest_block_height: block::Height,
54
55    /// Earliest block time
56    pub earliest_block_time: Time,
57
58    /// Latest block hash
59    #[serde(with = "cometbft::serializers::hash")]
60    pub latest_block_hash: Hash,
61
62    /// Latest app hash
63    #[serde(with = "cometbft::serializers::apphash")]
64    pub latest_app_hash: AppHash,
65
66    /// Latest block height
67    pub latest_block_height: block::Height,
68
69    /// Latest block time
70    pub latest_block_time: Time,
71
72    /// Are we catching up?
73    pub catching_up: bool,
74}