1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! `/validators` endpoint JSON-RPC wrapper

use serde::{Deserialize, Serialize};

use tendermint::{block, validator};

/// List validators for a specific block
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Request {
    pub height: block::Height,
}

impl Request {
    /// List validators for a specific block
    pub fn new(height: block::Height) -> Self {
        Self { height }
    }
}

impl crate::Request for Request {
    type Response = Response;

    fn method(&self) -> crate::Method {
        crate::Method::Validators
    }
}

/// Validator responses
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
    /// Block height
    pub block_height: block::Height,

    /// Validator list
    pub validators: Vec<validator::Info>,
}

impl crate::Response for Response {}