@@ -44,7 +44,7 @@ pub struct Level {
4444 /// to recursively following `current`
4545 current_chain_length : usize ,
4646 /// The head of this level
47- current : Option < i64 > ,
47+ head : Option < i64 > ,
4848}
4949
5050impl Level {
@@ -53,25 +53,25 @@ impl Level {
5353 Level {
5454 max_length,
5555 current_chain_length : 0 ,
56- current : None ,
56+ head : None ,
5757 }
5858 }
5959
6060 /// Creates a new level from stored state
61- pub fn restore ( max_length : usize , current_chain_length : usize , current : Option < i64 > ) -> Level {
61+ pub fn restore ( max_length : usize , current_chain_length : usize , head : Option < i64 > ) -> Level {
6262 Level {
6363 max_length,
6464 current_chain_length,
65- current ,
65+ head ,
6666 }
6767 }
6868
6969 /// Update the current head of this level. If delta is true then it means
7070 /// that given state group will (probably) reference the previous head.
7171 ///
7272 /// Panics if `delta` is true and the level is already full.
73- fn update ( & mut self , current : i64 , delta : bool ) {
74- self . current = Some ( current ) ;
73+ fn update ( & mut self , new_head : i64 , delta : bool ) {
74+ self . head = Some ( new_head ) ;
7575
7676 if delta {
7777 // If we're referencing the previous head then increment our chain
@@ -87,9 +87,19 @@ impl Level {
8787 }
8888 }
8989
90+ /// Get the max length of the level
91+ pub fn get_max_length ( & self ) -> usize {
92+ self . max_length
93+ }
94+
95+ /// Get the current length of the level
96+ pub fn get_current_length ( & self ) -> usize {
97+ self . current_chain_length
98+ }
99+
90100 /// Get the current head of the level
91- pub fn get_current ( & self ) -> Option < i64 > {
92- self . current
101+ pub fn get_head ( & self ) -> Option < i64 > {
102+ self . head
93103 }
94104
95105 /// Whether there is space in the current chain at this level. If not then a
@@ -142,12 +152,11 @@ impl<'a> Compressor<'a> {
142152 /// in which case the levels heads are also known
143153 pub fn compress_from_save (
144154 original_state_map : & ' a BTreeMap < i64 , StateGroupEntry > ,
145- // level_info: &[(usize, usize, Option<i64>)],
146155 level_info : & [ Level ] ,
147156 ) -> Compressor < ' a > {
148157 let levels = level_info
149158 . iter ( )
150- . map ( |l| Level :: restore ( ( * l) . max_length , ( * l) . current_chain_length , ( * l) . current ) )
159+ . map ( |l| Level :: restore ( ( * l) . max_length , ( * l) . current_chain_length , ( * l) . head ) )
151160 . collect ( ) ;
152161
153162 let mut compressor = Compressor {
@@ -200,7 +209,7 @@ impl<'a> Compressor<'a> {
200209 let mut prev_state_group = None ;
201210 for level in & mut self . levels {
202211 if level. has_space ( ) {
203- prev_state_group = level. get_current ( ) ;
212+ prev_state_group = level. get_head ( ) ;
204213 level. update ( state_group, true ) ;
205214 break ;
206215 } else {
0 commit comments