@@ -11,19 +11,19 @@ use cardano_blockchain_types::{Network, Point};
1111use tracing:: debug;
1212
1313use crate :: mithril_snapshot_sync:: { get_mithril_tip, MITHRIL_IMMUTABLE_SUB_DIRECTORY } ;
14- /// A Representation of a Snapshot Path and its represented Immutable File Number .
14+ /// A representation of a Snapshot Path and its represented immutable file number .
1515#[ derive( Clone , Debug ) ]
1616pub ( crate ) struct SnapshotId {
17- /// The Snapshot Path
17+ /// The snapshot path
1818 path : PathBuf ,
19- /// The largest Immutable File Number
19+ /// The largest immutable file number
2020 file : u64 ,
21- /// The Tip of the Snapshot
21+ /// The tip of the Snapshot
2222 tip : Point ,
2323}
2424
2525impl SnapshotId {
26- /// See if we can Parse the path into an immutable file number.
26+ /// See if we can parse the path into an immutable file number.
2727 pub ( crate ) fn parse_path ( path : & Path ) -> Option < u64 > {
2828 // Path must actually exist, and be a directory.
2929 if !path. is_dir ( ) {
@@ -42,7 +42,7 @@ impl SnapshotId {
4242 }
4343
4444 /// Try and create a new `SnapshotID` from a given path.
45- /// Immutable TIP must be provided.
45+ /// Immutable tip must be provided.
4646 pub ( crate ) fn new ( path : & Path , tip : Point ) -> Option < Self > {
4747 debug ! ( "Trying to Get SnapshotID of: {}" , path. to_string_lossy( ) ) ;
4848 let immutable_file = SnapshotId :: parse_path ( path) ?;
@@ -56,7 +56,7 @@ impl SnapshotId {
5656 }
5757
5858 /// Try and create a new `SnapshotID` from a given path.
59- /// Includes properly getting the Immutable TIP.
59+ /// Includes properly getting the immutable TIP.
6060 pub ( crate ) async fn try_new ( chain : Network , path : & Path ) -> Option < Self > {
6161 let Ok ( tip) = get_mithril_tip ( chain, path) . await else {
6262 return None ;
@@ -65,28 +65,28 @@ impl SnapshotId {
6565 SnapshotId :: new ( path, tip. point ( ) )
6666 }
6767
68- /// Get the Immutable Blockchain path from this `SnapshotId`
68+ /// Get the immutable blockchain path from this `SnapshotId`
6969 pub ( crate ) fn immutable_path ( & self ) -> PathBuf {
7070 let mut immutable = self . path . clone ( ) ;
7171 immutable. push ( MITHRIL_IMMUTABLE_SUB_DIRECTORY ) ;
7272
7373 immutable
7474 }
7575
76- /// Get the Blockchain path from this `SnapshotId`
76+ /// Get the blockchain path from this `SnapshotId`
7777 pub ( crate ) fn path ( & self ) -> PathBuf {
7878 self . path . clone ( )
7979 }
8080
81- /// Get the Blockchain path from this `SnapshotId` only if it actually exists.
81+ /// Get the blockchain path from this `SnapshotId` only if it actually exists.
8282 pub ( crate ) fn path_if_exists ( & self ) -> Option < PathBuf > {
8383 if self . tip . is_unknown ( ) {
8484 return None ;
8585 }
8686 Some ( self . path . clone ( ) )
8787 }
8888
89- /// Get the Tip of the Immutable Blockchain from this `SnapshotId`
89+ /// Get the tip of the immutable blockchain from this `SnapshotId`
9090 pub ( crate ) fn tip ( & self ) -> Point {
9191 self . tip . clone ( )
9292 }
@@ -122,27 +122,24 @@ impl Display for SnapshotId {
122122 }
123123}
124124
125- // Normal Comparisons to simplify code.
125+ // Normal comparisons to simplify code.
126126impl PartialEq for SnapshotId {
127- // Equality ONLY checks the Immutable File Number, not the path.
128- // This is because the Filename is already the ImmutableFileNumber
127+ // Equality ONLY checks the `file` (immutable file number), not the path.
129128 fn eq ( & self , other : & Self ) -> bool {
130129 self . file == other. file
131130 }
132131}
133132
134133impl PartialOrd for SnapshotId {
135- // Equality ONLY checks the Immutable File Number, not the path.
136- // This is because the Filename is already the ImmutableFileNumber
134+ // Equality ONLY checks the `file` (immutable file number), not the path.
137135 fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
138136 self . file . partial_cmp ( & other. file )
139137 }
140138}
141139
142- // Allows us to compare a SnapshotID against Some(SnapshotID).
140+ // Allows us to compare a ` SnapshotID` against Some(` SnapshotID` ).
143141impl PartialEq < Option < SnapshotId > > for SnapshotId {
144- // Equality ONLY checks the Immutable File Number, not the path.
145- // This is because the Filename is already the ImmutableFileNumber
142+ // Equality ONLY checks the `file` (immutable file number), not the path.
146143 fn eq ( & self , other : & Option < Self > ) -> bool {
147144 match other {
148145 None => false ,
@@ -152,8 +149,7 @@ impl PartialEq<Option<SnapshotId>> for SnapshotId {
152149}
153150
154151impl PartialOrd < Option < SnapshotId > > for SnapshotId {
155- // Equality ONLY checks the Immutable File Number, not the path.
156- // This is because the Filename is already the ImmutableFileNumber
152+ // Equality ONLY checks the `file` (immutable file number), not the path.
157153 fn partial_cmp ( & self , other : & Option < Self > ) -> Option < Ordering > {
158154 match other {
159155 None => Some ( Ordering :: Greater ) , // Anything is always greater than None.
@@ -162,18 +158,16 @@ impl PartialOrd<Option<SnapshotId>> for SnapshotId {
162158 }
163159}
164160
165- // Allows us to compare a SnapshotID against u64 (Just the Immutable File Number ).
161+ // Allows us to compare a ` SnapshotID` against u64 (just the immutable file number ).
166162impl PartialEq < u64 > for SnapshotId {
167- // Equality ONLY checks the Immutable File Number, not the path.
168- // This is because the Filename is already the ImmutableFileNumber
163+ // Equality ONLY checks the `file` (immutable file number), not the path.
169164 fn eq ( & self , other : & u64 ) -> bool {
170165 self . file == * other
171166 }
172167}
173168
174169impl PartialOrd < u64 > for SnapshotId {
175- // Equality ONLY checks the Immutable File Number, not the path.
176- // This is because the Filename is already the ImmutableFileNumber
170+ // Equality ONLY checks the `file` (immutable file number), not the path.
177171 fn partial_cmp ( & self , other : & u64 ) -> Option < Ordering > {
178172 self . file . partial_cmp ( other)
179173 }
0 commit comments