cometbft_rpc/endpoint/
consensus_params.rs

1//! `/consensus_params` endpoint JSON-RPC wrapper
2
3use cometbft::block::Height;
4use serde::{Deserialize, Serialize};
5
6use crate::{dialect::Dialect, request::RequestMessage};
7
8/// Get the consensus parameters.
9///
10/// If no height is supplied, the latest consensus parameters will be returned.
11#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
12pub struct Request {
13    pub height: Option<Height>,
14}
15
16impl Request {
17    /// Constructor with optional height.
18    pub fn new(maybe_height: Option<Height>) -> Self {
19        Self {
20            height: maybe_height,
21        }
22    }
23}
24
25impl RequestMessage for Request {
26    fn method(&self) -> crate::Method {
27        crate::Method::ConsensusParams
28    }
29}
30
31impl<S: Dialect> crate::Request<S> for Request {
32    type Response = Response;
33}
34
35impl<S: Dialect> crate::SimpleRequest<S> for Request {
36    type Output = Response;
37}
38
39/// Consensus parameters response.
40#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
41pub struct Response {
42    pub block_height: Height,
43    pub consensus_params: cometbft::consensus::Params,
44}
45
46impl crate::Response for Response {}