1//! Response type for the `getmininginfo` RPC.
23use zebra_chain::parameters::Network;
45/// Response to a `getmininginfo` RPC request.
6#[derive(Debug, Default, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
7pub struct Response {
8/// The current tip height.
9#[serde(rename = "blocks")]
10tip_height: u32,
1112/// The size of the last mined block if any.
13#[serde(rename = "currentblocksize", skip_serializing_if = "Option::is_none")]
14current_block_size: Option<usize>,
1516/// The number of transactions in the last mined block if any.
17#[serde(rename = "currentblocktx", skip_serializing_if = "Option::is_none")]
18current_block_tx: Option<usize>,
1920/// The estimated network solution rate in Sol/s.
21networksolps: u64,
2223/// The estimated network solution rate in Sol/s.
24networkhashps: u64,
2526/// Current network name as defined in BIP70 (main, test, regtest)
27chain: String,
2829/// If using testnet or not
30testnet: bool,
31}
3233impl Response {
34/// Creates a new `getmininginfo` response
35pub fn new(
36 tip_height: u32,
37 current_block_size: Option<usize>,
38 current_block_tx: Option<usize>,
39 network: Network,
40 networksolps: u64,
41 ) -> Self {
42Self {
43 tip_height,
44 current_block_size,
45 current_block_tx,
46 networksolps,
47 networkhashps: networksolps,
48 chain: network.bip70_network_name(),
49 testnet: network.is_a_test_network(),
50 }
51 }
52}