chik_protocol/pos_quality.rs
1use chik_traits::chik_error::Result;
2
3// The actual space in bytes of a plot, is _expected_plot_size(k) * UI_ACTUAL_SPACE_CONSTANT_FACTO
4// This is not used in consensus, only for display purposes
5
6pub const UI_ACTUAL_SPACE_CONSTANT_FACTOR: f32 = 0.78;
7
8pub fn expected_plot_size(k: u32) -> Result<u64> {
9 // """
10 // Given the plot size parameter k (which is between 32 and 59), computes the
11 // expected size of the plot in bytes (times a constant factor). This is based on efficient encoding
12 // of the plot, and aims to be scale agnostic, so larger plots don't
13 // necessarily get more rewards per byte. The +1 is added to give half a bit more space per entry, which
14 // is necessary to store the entries in the plot.
15 // """
16
17 Ok((2 * k as u64 + 1) * (1_u64 << (k - 1)))
18}
19
20// TODO: Update this when new plot format releases
21#[cfg(feature = "py-bindings")]
22#[pyo3::pyfunction]
23#[pyo3(name = "expected_plot_size")]
24pub fn py_expected_plot_size(k: u32) -> pyo3::PyResult<u64> {
25 // """
26 // Given the plot size parameter k (which is between 32 and 59), computes the
27 // expected size of the plot in bytes (times a constant factor). This is based on efficient encoding
28 // of the plot, and aims to be scale agnostic, so larger plots don't
29 // necessarily get more rewards per byte. The +1 is added to give half a bit more space per entry, which
30 // is necessary to store the entries in the plot.
31 // """
32
33 Ok(expected_plot_size(k)?)
34}