1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use storage_proofs_core::util::NODE_SIZE;
use storage_proofs_update::constants::{h_default, partition_count};

use crate::types::{PoRepConfig, SectorSize, UpdateProofPartitions};

#[derive(Clone, Copy, Debug)]
pub struct SectorUpdateConfig {
    pub sector_size: SectorSize,
    pub nodes_count: usize,
    pub update_partitions: UpdateProofPartitions,
    pub h: usize,
}

impl SectorUpdateConfig {
    pub fn from_porep_config(porep_config: &PoRepConfig) -> Self {
        let nodes_count = u64::from(porep_config.sector_size) as usize / NODE_SIZE;

        SectorUpdateConfig {
            sector_size: porep_config.sector_size,
            nodes_count,
            update_partitions: UpdateProofPartitions::from(partition_count(nodes_count)),
            h: h_default(nodes_count),
        }
    }
}