44//! a small piece cache. It fully manages farming and plotting process, including listening to node
55//! notifications, producing solutions and singing rewards.
66
7+ pub mod direct_io_file;
78pub mod farming;
89pub mod identity;
910mod metrics;
@@ -13,7 +14,6 @@ pub mod plot_cache;
1314mod plotted_sectors;
1415mod plotting;
1516mod reward_signing;
16- pub mod unbuffered_io_file_windows;
1717
1818use crate :: disk_piece_cache:: { DiskPieceCache , DiskPieceCacheError } ;
1919use crate :: farm:: {
@@ -22,6 +22,7 @@ use crate::farm::{
2222} ;
2323use crate :: node_client:: NodeClient ;
2424use crate :: plotter:: Plotter ;
25+ use crate :: single_disk_farm:: direct_io_file:: { DirectIoFile , DISK_SECTOR_SIZE } ;
2526use crate :: single_disk_farm:: farming:: rayon_files:: RayonFiles ;
2627use crate :: single_disk_farm:: farming:: {
2728 farming, slot_notification_forwarder, FarmingOptions , PlotAudit ,
@@ -37,9 +38,6 @@ use crate::single_disk_farm::plotting::{
3738 plotting, plotting_scheduler, PlottingOptions , PlottingSchedulerOptions , SectorPlottingOptions ,
3839} ;
3940use crate :: single_disk_farm:: reward_signing:: reward_signing;
40- #[ cfg( windows) ]
41- use crate :: single_disk_farm:: unbuffered_io_file_windows:: UnbufferedIoFileWindows ;
42- use crate :: single_disk_farm:: unbuffered_io_file_windows:: DISK_SECTOR_SIZE ;
4341use crate :: utils:: { tokio_rayon_spawn_handler, AsyncJoinOnDrop } ;
4442use crate :: { farm, KNOWN_PEERS_CACHE_SIZE } ;
4543use async_lock:: { Mutex as AsyncMutex , RwLock as AsyncRwLock } ;
@@ -75,8 +73,6 @@ use subspace_core_primitives::{
7573} ;
7674use subspace_erasure_coding:: ErasureCoding ;
7775use subspace_farmer_components:: file_ext:: FileExt ;
78- #[ cfg( not( windows) ) ]
79- use subspace_farmer_components:: file_ext:: OpenOptionsExt ;
8076use subspace_farmer_components:: reading:: ReadSectorRecordChunksMode ;
8177use subspace_farmer_components:: sector:: { sector_size, SectorMetadata , SectorMetadataChecksummed } ;
8278use subspace_farmer_components:: { FarmerProtocolInfo , ReadAtSync } ;
@@ -753,14 +749,8 @@ struct SingleDiskFarmInit {
753749 identity : Identity ,
754750 single_disk_farm_info : SingleDiskFarmInfo ,
755751 single_disk_farm_info_lock : Option < SingleDiskFarmInfoLock > ,
756- #[ cfg( not( windows) ) ]
757- plot_file : Arc < File > ,
758- #[ cfg( windows) ]
759- plot_file : Arc < UnbufferedIoFileWindows > ,
760- #[ cfg( not( windows) ) ]
761- metadata_file : File ,
762- #[ cfg( windows) ]
763- metadata_file : UnbufferedIoFileWindows ,
752+ plot_file : Arc < DirectIoFile > ,
753+ metadata_file : DirectIoFile ,
764754 metadata_header : PlotMetadataHeader ,
765755 target_sector_count : u16 ,
766756 sectors_metadata : Arc < AsyncRwLock < Vec < SectorMetadataChecksummed > > > ,
@@ -993,17 +983,7 @@ impl SingleDiskFarm {
993983 let farming_plot_fut = task:: spawn_blocking ( || {
994984 farming_thread_pool
995985 . install ( move || {
996- #[ cfg( windows) ]
997- {
998- RayonFiles :: open_with (
999- & directory. join ( Self :: PLOT_FILE ) ,
1000- UnbufferedIoFileWindows :: open,
1001- )
1002- }
1003- #[ cfg( not( windows) ) ]
1004- {
1005- RayonFiles :: open ( & directory. join ( Self :: PLOT_FILE ) )
1006- }
986+ RayonFiles :: open_with ( & directory. join ( Self :: PLOT_FILE ) , DirectIoFile :: open)
1007987 } )
1008988 . map ( |farming_plot| ( farming_plot, farming_thread_pool) )
1009989 } ) ;
@@ -1474,19 +1454,7 @@ impl SingleDiskFarm {
14741454 let target_sector_count = allocated_space_distribution. target_sector_count ;
14751455
14761456 let metadata_file_path = directory. join ( Self :: METADATA_FILE ) ;
1477- #[ cfg( not( windows) ) ]
1478- let metadata_file = OpenOptions :: new ( )
1479- . read ( true )
1480- . write ( true )
1481- . create ( true )
1482- . advise_random_access ( )
1483- . open ( & metadata_file_path) ?;
1484-
1485- #[ cfg( not( windows) ) ]
1486- metadata_file. advise_random_access ( ) ?;
1487-
1488- #[ cfg( windows) ]
1489- let metadata_file = UnbufferedIoFileWindows :: open ( & metadata_file_path) ?;
1457+ let metadata_file = DirectIoFile :: open ( & metadata_file_path) ?;
14901458
14911459 let metadata_size = metadata_file. size ( ) ?;
14921460 let expected_metadata_size = allocated_space_distribution. metadata_file_size ;
@@ -1576,19 +1544,7 @@ impl SingleDiskFarm {
15761544 Arc :: new ( AsyncRwLock :: new ( sectors_metadata) )
15771545 } ;
15781546
1579- #[ cfg( not( windows) ) ]
1580- let plot_file = OpenOptions :: new ( )
1581- . read ( true )
1582- . write ( true )
1583- . create ( true )
1584- . advise_random_access ( )
1585- . open ( directory. join ( Self :: PLOT_FILE ) ) ?;
1586-
1587- #[ cfg( not( windows) ) ]
1588- plot_file. advise_random_access ( ) ?;
1589-
1590- #[ cfg( windows) ]
1591- let plot_file = UnbufferedIoFileWindows :: open ( & directory. join ( Self :: PLOT_FILE ) ) ?;
1547+ let plot_file = DirectIoFile :: open ( & directory. join ( Self :: PLOT_FILE ) ) ?;
15921548
15931549 if plot_file. size ( ) ? != allocated_space_distribution. plot_file_size {
15941550 // Allocating the whole file (`set_len` below can create a sparse file, which will cause
@@ -1731,13 +1687,7 @@ impl SingleDiskFarm {
17311687 pub fn read_all_sectors_metadata (
17321688 directory : & Path ,
17331689 ) -> io:: Result < Vec < SectorMetadataChecksummed > > {
1734- #[ cfg( not( windows) ) ]
1735- let metadata_file = OpenOptions :: new ( )
1736- . read ( true )
1737- . open ( directory. join ( Self :: METADATA_FILE ) ) ?;
1738-
1739- #[ cfg( windows) ]
1740- let metadata_file = UnbufferedIoFileWindows :: open ( & directory. join ( Self :: METADATA_FILE ) ) ?;
1690+ let metadata_file = DirectIoFile :: open ( & directory. join ( Self :: METADATA_FILE ) ) ?;
17411691
17421692 let metadata_size = metadata_file. size ( ) ?;
17431693 let sector_metadata_size = SectorMetadataChecksummed :: encoded_size ( ) ;
0 commit comments