zebra_rpc/config/mining.rs
1//! Mining config
2
3use serde::{Deserialize, Serialize};
4use serde_with::{serde_as, DisplayFromStr};
5
6use zcash_address::ZcashAddress;
7
8/// Mining configuration section.
9#[serde_as]
10#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
11#[serde(deny_unknown_fields, default)]
12pub struct Config {
13 /// Address for receiving miner subsidy and tx fees.
14 ///
15 /// Used in coinbase tx constructed in `getblocktemplate` RPC.
16 #[serde_as(as = "Option<DisplayFromStr>")]
17 pub miner_address: Option<ZcashAddress>,
18
19 // TODO: Internal miner config code was removed as part of https://github.com/ZcashFoundation/zebra/issues/8180
20 // Find the removed code at https://github.com/ZcashFoundation/zebra/blob/v1.5.1/zebra-rpc/src/config/mining.rs#L18-L38
21 // Restore the code when conditions are met. https://github.com/ZcashFoundation/zebra/issues/8183
22 /// Extra data to include in coinbase transaction inputs.
23 /// Limited to around 95 bytes by the consensus rules.
24 ///
25 /// If this string is hex-encoded, it will be hex-decoded into bytes.
26 /// Otherwise, it will be UTF-8 encoded into bytes.
27 pub extra_coinbase_data: Option<String>,
28
29 /// Mine blocks using Zebra's internal miner, without an external mining pool or equihash solver.
30 ///
31 /// This experimental feature is only supported on regtest as it uses null solutions and skips checking
32 /// for a valid Proof of Work.
33 ///
34 /// The internal miner is off by default.
35 #[serde(default)]
36 pub internal_miner: bool,
37}
38
39impl Config {
40 /// Is the internal miner enabled using at least one thread?
41 #[cfg(feature = "internal-miner")]
42 pub fn is_internal_miner_enabled(&self) -> bool {
43 // TODO: Changed to return always false so internal miner is never started. Part of https://github.com/ZcashFoundation/zebra/issues/8180
44 // Find the removed code at https://github.com/ZcashFoundation/zebra/blob/v1.5.1/zebra-rpc/src/config/mining.rs#L83
45 // Restore the code when conditions are met. https://github.com/ZcashFoundation/zebra/issues/8183
46 self.internal_miner
47 }
48}