kaspa_mining/block_template/policy.rs
1use kaspa_consensus_core::mass::BlockLaneLimits;
2
3/// Policy houses the policy (configuration parameters) which is used to control
4/// the generation of block templates. See the documentation for
5/// NewBlockTemplate for more details on how each of these parameters are used.
6#[derive(Clone)]
7pub struct Policy {
8 /// max_block_mass is the maximum block mass to be used when generating a block template.
9 pub(crate) max_block_mass: u64,
10 /// lanes_per_block_limit is the maximum number of distinct subnet lanes a block template may include.
11 pub(crate) lanes_per_block_limit: usize,
12 /// gas_per_lane_limit is the maximum total gas per lane in a block template.
13 pub(crate) gas_per_lane_limit: u64,
14}
15
16impl Policy {
17 pub fn new(max_block_mass: u64, block_lane_limits: BlockLaneLimits) -> Self {
18 Self {
19 max_block_mass,
20 lanes_per_block_limit: block_lane_limits.lanes_per_block,
21 gas_per_lane_limit: block_lane_limits.gas_per_lane,
22 }
23 }
24}