zebra_rpc/methods/types/
get_mining_info.rs
1use derive_getters::Getters;
4use derive_new::new;
5use zebra_chain::parameters::Network;
6
7#[derive(
9 Debug, Default, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, Getters, new,
10)]
11pub struct GetMiningInfoResponse {
12 #[serde(rename = "blocks")]
14 tip_height: u32,
15
16 #[serde(rename = "currentblocksize", skip_serializing_if = "Option::is_none")]
18 #[getter(copy)]
19 current_block_size: Option<usize>,
20
21 #[serde(rename = "currentblocktx", skip_serializing_if = "Option::is_none")]
23 #[getter(copy)]
24 current_block_tx: Option<usize>,
25
26 networksolps: u64,
28
29 networkhashps: u64,
31
32 chain: String,
34
35 testnet: bool,
37}
38
39impl GetMiningInfoResponse {
40 pub(crate) fn new_internal(
42 tip_height: u32,
43 current_block_size: Option<usize>,
44 current_block_tx: Option<usize>,
45 network: Network,
46 networksolps: u64,
47 ) -> Self {
48 Self {
49 tip_height,
50 current_block_size,
51 current_block_tx,
52 networksolps,
53 networkhashps: networksolps,
54 chain: network.bip70_network_name(),
55 testnet: network.is_a_test_network(),
56 }
57 }
58}