File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -195,12 +195,21 @@ impl LedgersToKeep {
195195impl < ' a > FromIterator < & ' a ArcBlockWithHash > for LedgersToKeep {
196196 fn from_iter < T : IntoIterator < Item = & ' a ArcBlockWithHash > > ( iter : T ) -> Self {
197197 let mut res = Self :: new ( ) ;
198- for block in iter {
198+ let best_tip = iter. into_iter ( ) . fold ( None , |best_tip , block| {
199199 res. add_snarked ( block. snarked_ledger_hash ( ) . clone ( ) ) ;
200- res. add_snarked ( block. staking_epoch_ledger_hash ( ) . clone ( ) ) ;
201- res. add_snarked ( block. next_epoch_ledger_hash ( ) . clone ( ) ) ;
202200 res. add_staged ( Arc :: new ( block. staged_ledger_hashes ( ) . clone ( ) ) ) ;
201+ match best_tip {
202+ None => Some ( block) ,
203+ Some ( tip) if tip. height ( ) < block. height ( ) => Some ( block) ,
204+ old => old,
205+ }
206+ } ) ;
207+
208+ if let Some ( best_tip) = best_tip {
209+ res. add_snarked ( best_tip. staking_epoch_ledger_hash ( ) . clone ( ) ) ;
210+ res. add_snarked ( best_tip. next_epoch_ledger_hash ( ) . clone ( ) ) ;
203211 }
212+
204213 res
205214 }
206215}
You can’t perform that action at this time.
0 commit comments