11use crate :: single_disk_farm:: {
2- BackgroundTaskError , Handlers , PlotMetadataHeader , SectorExpirationDetails ,
3- SectorPlottingDetails , SectorUpdate , RESERVED_PLOT_METADATA ,
2+ BackgroundTaskError , Handlers , PlotMetadataHeader , SectorUpdate , RESERVED_PLOT_METADATA ,
43} ;
54use crate :: thread_pool_manager:: PlottingThreadPoolManager ;
65use crate :: utils:: AsyncJoinOnDrop ;
@@ -10,7 +9,7 @@ use atomic::Atomic;
109use futures:: channel:: { mpsc, oneshot} ;
1110use futures:: { select, FutureExt , SinkExt , StreamExt } ;
1211use lru:: LruCache ;
13- use parity_scale_codec:: Encode ;
12+ use parity_scale_codec:: { Decode , Encode } ;
1413use std:: collections:: HashMap ;
1514use std:: fs:: File ;
1615use std:: io;
@@ -46,6 +45,55 @@ const ARCHIVED_SEGMENTS_CACHE_SIZE: NonZeroUsize = NonZeroUsize::new(1000).expec
4645/// Get piece retry attempts number.
4746const PIECE_GETTER_RETRY_NUMBER : NonZeroU16 = NonZeroU16 :: new ( 4 ) . expect ( "Not zero; qed" ) ;
4847
48+ /// Details about sector currently being plotted
49+ #[ derive( Debug , Clone , Encode , Decode ) ]
50+ pub enum SectorPlottingDetails {
51+ /// Starting plotting of a sector
52+ Starting {
53+ /// Progress so far in % (not including this sector)
54+ progress : f32 ,
55+ /// Whether sector is being replotted
56+ replotting : bool ,
57+ /// Whether this is the last sector queued so far
58+ last_queued : bool ,
59+ } ,
60+ /// Downloading sector pieces
61+ Downloading ,
62+ /// Downloaded sector pieces
63+ Downloaded ( Duration ) ,
64+ /// Encoding sector pieces
65+ Encoding ,
66+ /// Encoded sector pieces
67+ Encoded ( Duration ) ,
68+ /// Writing sector
69+ Writing ,
70+ /// Written sector
71+ Written ( Duration ) ,
72+ /// Finished plotting
73+ Finished {
74+ /// Information about plotted sector
75+ plotted_sector : PlottedSector ,
76+ /// Information about old plotted sector that was replaced
77+ old_plotted_sector : Option < PlottedSector > ,
78+ /// How much time it took to plot a sector
79+ time : Duration ,
80+ } ,
81+ }
82+
83+ /// Details about sector expiration
84+ #[ derive( Debug , Clone , Encode , Decode ) ]
85+ pub enum SectorExpirationDetails {
86+ /// Sector expiration became known
87+ Determined {
88+ /// Segment index at which sector expires
89+ expires_at : SegmentIndex ,
90+ } ,
91+ /// Sector will expire at the next segment index and should be replotted
92+ AboutToExpire ,
93+ /// Sector already expired
94+ Expired ,
95+ }
96+
4997pub ( super ) struct SectorToPlot {
5098 sector_index : SectorIndex ,
5199 /// Progress so far in % (not including this sector)
0 commit comments