zebra_rpc/config/mining.rs
1//! Mining config
2
3use serde::{Deserialize, Serialize};
4
5use zebra_chain::transparent;
6
7/// Mining configuration section.
8#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
9#[serde(deny_unknown_fields, default)]
10pub struct Config {
11 /// The address used for miner payouts.
12 /// Zebra currently only supports P2SH and P2PKH transparent addresses.
13 ///
14 /// Zebra sends mining fees and miner rewards to this address in the
15 /// `getblocktemplate` RPC coinbase transaction.
16 pub miner_address: Option<transparent::Address>,
17
18 // TODO: Internal miner config code was removed as part of https://github.com/ZcashFoundation/zebra/issues/8180
19 // Find the removed code at https://github.com/ZcashFoundation/zebra/blob/v1.5.1/zebra-rpc/src/config/mining.rs#L18-L38
20 // Restore the code when conditions are met. https://github.com/ZcashFoundation/zebra/issues/8183
21 /// Extra data to include in coinbase transaction inputs.
22 /// Limited to around 95 bytes by the consensus rules.
23 ///
24 /// If this string is hex-encoded, it will be hex-decoded into bytes.
25 /// Otherwise, it will be UTF-8 encoded into bytes.
26 pub extra_coinbase_data: Option<String>,
27
28 /// Should Zebra's block templates try to imitate `zcashd`?
29 ///
30 /// This developer-only config is not supported for general use.
31 /// TODO: remove this option as part of zcashd deprecation
32 pub debug_like_zcashd: bool,
33
34 /// Mine blocks using Zebra's internal miner, without an external mining pool or equihash solver.
35 ///
36 /// This experimental feature is only supported on regtest as it uses null solutions and skips checking
37 /// for a valid Proof of Work.
38 ///
39 /// The internal miner is off by default.
40 #[serde(default)]
41 pub internal_miner: bool,
42}
43
44impl Default for Config {
45 fn default() -> Self {
46 Self {
47 miner_address: None,
48 // For now, act like `zcashd` as much as possible.
49 // TODO: do we want to default to v5 transactions and Zebra coinbase data?
50 extra_coinbase_data: None,
51 debug_like_zcashd: true,
52 internal_miner: false,
53 }
54 }
55}
56
57impl Config {
58 /// Is the internal miner enabled using at least one thread?
59 #[cfg(feature = "internal-miner")]
60 pub fn is_internal_miner_enabled(&self) -> bool {
61 // TODO: Changed to return always false so internal miner is never started. Part of https://github.com/ZcashFoundation/zebra/issues/8180
62 // Find the removed code at https://github.com/ZcashFoundation/zebra/blob/v1.5.1/zebra-rpc/src/config/mining.rs#L83
63 // Restore the code when conditions are met. https://github.com/ZcashFoundation/zebra/issues/8183
64 self.internal_miner
65 }
66}