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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use crate::{PageNumber, PerPage};
use serde::{Deserialize, Serialize};
use tendermint::{block, validator};
pub const DEFAULT_VALIDATORS_PER_PAGE: u8 = 30;
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[non_exhaustive]
pub struct Request {
pub height: Option<block::Height>,
#[serde(with = "tendermint_proto::serializers::optional_from_str")]
pub page: Option<PageNumber>,
#[serde(with = "tendermint_proto::serializers::optional_from_str")]
pub per_page: Option<PerPage>,
}
impl Request {
pub fn new(
height: Option<block::Height>,
page: Option<PageNumber>,
per_page: Option<PerPage>,
) -> Self {
Self {
height,
page,
per_page,
}
}
}
impl Default for Request {
fn default() -> Self {
Self {
height: None,
page: None,
per_page: None,
}
}
}
impl crate::Request for Request {
type Response = Response;
fn method(&self) -> crate::Method {
crate::Method::Validators
}
}
impl crate::SimpleRequest for Request {}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[non_exhaustive]
pub struct Response {
pub block_height: block::Height,
pub validators: Vec<validator::Info>,
#[serde(with = "tendermint_proto::serializers::from_str")]
pub total: i32,
}
impl crate::Response for Response {}
impl Response {
pub fn new(block_height: block::Height, validators: Vec<validator::Info>, total: i32) -> Self {
Self {
block_height,
validators,
total,
}
}
}