diff --git a/crates/proof-of-space/src/lib.rs b/crates/proof-of-space/src/lib.rs index 60c6981..60262d7 100644 --- a/crates/proof-of-space/src/lib.rs +++ b/crates/proof-of-space/src/lib.rs @@ -45,7 +45,7 @@ pub use piece::{Piece, PieceMetadata, PiecePosition}; #[cfg(feature = "std")] pub use solution::find_solutions; pub use solution::Solution; -pub use y_value_manager::{XValueManager, YPos}; +pub use y_value_manager::{YValueManager, YPos}; pub use z_value_manager::ZValueManager; #[derive(Default, Encode, Decode, Clone, PartialEq, Eq, Debug, TypeInfo)] diff --git a/crates/proof-of-space/src/piece.rs b/crates/proof-of-space/src/piece.rs index b4afba9..9f41bdf 100644 --- a/crates/proof-of-space/src/piece.rs +++ b/crates/proof-of-space/src/piece.rs @@ -13,7 +13,7 @@ // limitations under the License. #[cfg(feature = "std")] use crate::{CellMetadata, DasKv, YPos, ZValueManager}; -use crate::{Decode, Encode, FarmerId, Segment, Vec, XValueManager}; +use crate::{Decode, Encode, FarmerId, Segment, Vec, YValueManager}; #[cfg(feature = "std")] use anyhow::{anyhow, Ok, Result}; use melo_das_primitives::Position; @@ -127,7 +127,7 @@ where farmer_id: &'a FarmerId, ) -> impl Iterator + 'a { self.segments.iter().map(move |segment| { - let y = XValueManager::::calculate_y(farmer_id, segment); + let y = YValueManager::::calculate_y(farmer_id, segment); (y, segment) }) } @@ -171,7 +171,7 @@ where CellMetadata { piece_metadata: metadata_clone.clone(), offset: index as u32 }; let x_value_manager = - XValueManager::::new(&metadata_clone, index as u32, x); + YValueManager::::new(&metadata_clone, index as u32, x); let x_pos = YPos::from_u32(index as u32); diff --git a/crates/proof-of-space/src/y_value_manager.rs b/crates/proof-of-space/src/y_value_manager.rs index 3116864..ef0d6fc 100644 --- a/crates/proof-of-space/src/y_value_manager.rs +++ b/crates/proof-of-space/src/y_value_manager.rs @@ -73,7 +73,7 @@ impl YPos { } /// Manages the X-value in a blockchain context, linking to `CellMetadata`. -pub struct XValueManager +pub struct YValueManager where BlockNumber: Clone + sp_std::hash::Hash + Encode + Decode, { @@ -82,7 +82,7 @@ where pos: YPos, } -impl XValueManager +impl YValueManager where BlockNumber: Clone + sp_std::hash::Hash + Encode + Decode, { @@ -100,7 +100,7 @@ where utils::fold_hash(&buffer) } - /// Constructs a new `XValueManager` instance. + /// Constructs a new `YValueManager` instance. pub fn new(piece_metadata: &PieceMetadata, index: u32, y: u32) -> Self { let pos = YPos::from_u32(index); Self { @@ -110,7 +110,7 @@ where } } - /// Generates a key for the current `XValueManager`. + /// Generates a key for the current `YValueManager`. pub fn key(&self) -> Vec { Self::key_by_x_pos(&self.pos, self.y) } @@ -197,8 +197,8 @@ mod tests { let segs = poly_to_segment_vec(&poly, &kzg, 0, chunk_len).unwrap(); - let y1 = XValueManager::::calculate_y(&FarmerId::default(), &segs[0]); - let y2 = XValueManager::::calculate_y(&FarmerId::default(), &segs[1]); + let y1 = YValueManager::::calculate_y(&FarmerId::default(), &segs[0]); + let y2 = YValueManager::::calculate_y(&FarmerId::default(), &segs[1]); if y1 == y2 { print!("y: {:?}\n", y1); @@ -299,7 +299,7 @@ mod tests { #[test] fn test_x_value_manager_new() { let piece_metadata = PieceMetadata::::default(); - let x_value_manager = XValueManager::new(&piece_metadata, 10, 20); + let x_value_manager = YValueManager::new(&piece_metadata, 10, 20); assert_eq!(x_value_manager.y, 20); assert_eq!(x_value_manager.pos, YPos::from_u32(10)); } @@ -307,9 +307,9 @@ mod tests { #[test] fn test_x_value_manager_key() { let piece_metadata = PieceMetadata::::default(); - let x_value_manager = XValueManager::new(&piece_metadata, 10, 20); + let x_value_manager = YValueManager::new(&piece_metadata, 10, 20); let key = x_value_manager.key(); - let expected_key = XValueManager::::key_by_x_pos(&YPos::from_u32(10), 20); + let expected_key = YValueManager::::key_by_x_pos(&YPos::from_u32(10), 20); assert_eq!(key, expected_key); } @@ -318,7 +318,7 @@ mod tests { let seg = get_mock_seg(bs, 0, 0, &proof, FIELD_ELEMENTS_PER_SEGMENT); - let y = XValueManager::::calculate_y(&farmer_id, &seg); + let y = YValueManager::::calculate_y(&farmer_id, &seg); assert!(y == y_e); } @@ -339,12 +339,12 @@ mod tests { let index = 5; let y = 10; - let x_value_manager = XValueManager::new(&piece_metadata, index, y); + let x_value_manager = YValueManager::new(&piece_metadata, index, y); assert_eq!(x_value_manager.pos, YPos::from_u32(index)); let key = x_value_manager.key(); - let expected_key = XValueManager::::key_by_x_pos(&YPos::from_u32(index), y); + let expected_key = YValueManager::::key_by_x_pos(&YPos::from_u32(index), y); assert_eq!(key, expected_key); } @@ -403,7 +403,7 @@ mod tests { &mut db, ); - let x_value_manager = XValueManager::new(&PieceMetadata::::default(), 0, Y1); + let x_value_manager = YValueManager::new(&PieceMetadata::::default(), 0, Y1); let match_cells_set = x_value_manager.match_cells(&mut db).unwrap(); assert_eq!(match_cells_set.len(), 1); @@ -416,7 +416,7 @@ mod tests { let index = 5; let y = 10; - let x_value_manager = XValueManager::new(&piece_metadata, index, y); + let x_value_manager = YValueManager::new(&piece_metadata, index, y); x_value_manager.save(&mut db); diff --git a/crates/proof-of-space/src/z_value_manager.rs b/crates/proof-of-space/src/z_value_manager.rs index 7cc6f9e..c931dd2 100644 --- a/crates/proof-of-space/src/z_value_manager.rs +++ b/crates/proof-of-space/src/z_value_manager.rs @@ -14,7 +14,7 @@ #[cfg(feature = "std")] use crate::DasKv; -use crate::{utils, BlakeTwo256, CellMetadata, Decode, Encode, FarmerId, HashT, XValueManager}; +use crate::{utils, BlakeTwo256, CellMetadata, Decode, Encode, FarmerId, HashT, YValueManager}; #[cfg(feature = "std")] use anyhow::{Context, Result}; use melo_das_primitives::Segment; @@ -143,8 +143,8 @@ where ) -> bool { let calculated_z = Self::calculate_z(left_cell, right_cell); let is_pair = left_cell_metadata.is_pair(right_cell_metadata); - let is_y_equal = XValueManager::::calculate_y(farmer_id, left_cell) == - XValueManager::::calculate_y(farmer_id, right_cell); + let is_y_equal = YValueManager::::calculate_y(farmer_id, left_cell) == + YValueManager::::calculate_y(farmer_id, right_cell); z == calculated_z && is_pair && is_y_equal } }