@@ -559,35 +559,36 @@ impl ValidatorsDiff {
559
559
. map_err ( |_| Error :: BalancesIncompleteChunk ) ?;
560
560
561
561
if let Some ( x_arc) = xs. get_mut ( index as usize ) {
562
- let mut x = ( * * x_arc) . clone ( ) ;
562
+ let mut v = ( * * x_arc) . clone ( ) ;
563
563
// Note: a pubkey change implies index re-use. In that case over-write
564
564
// withdrawal_credentials and slashed inconditionally as their default values
565
565
// are valid values.
566
566
let pubkey_changed = diff. pubkey != * EMPTY_PUBKEY ;
567
567
if pubkey_changed {
568
- x . pubkey = diff. pubkey ;
568
+ v . pubkey = diff. pubkey ;
569
569
}
570
570
if pubkey_changed || diff. withdrawal_credentials != Hash256 :: ZERO {
571
- x . withdrawal_credentials = diff. withdrawal_credentials ;
571
+ v . withdrawal_credentials = diff. withdrawal_credentials ;
572
572
}
573
573
if diff. effective_balance != 0 {
574
- x . effective_balance = x . effective_balance . wrapping_add ( diff. effective_balance ) ;
574
+ v . effective_balance = v . effective_balance . wrapping_add ( diff. effective_balance ) ;
575
575
}
576
576
if pubkey_changed || diff. slashed {
577
- x . slashed = diff. slashed ;
577
+ v . slashed = diff. slashed ;
578
578
}
579
579
if diff. activation_eligibility_epoch != Epoch :: new ( 0 ) {
580
- x . activation_eligibility_epoch = diff. activation_eligibility_epoch ;
580
+ v . activation_eligibility_epoch = diff. activation_eligibility_epoch ;
581
581
}
582
582
if diff. activation_epoch != Epoch :: new ( 0 ) {
583
- x . activation_epoch = diff. activation_epoch ;
583
+ v . activation_epoch = diff. activation_epoch ;
584
584
}
585
585
if diff. exit_epoch != Epoch :: new ( 0 ) {
586
- x . exit_epoch = diff. exit_epoch ;
586
+ v . exit_epoch = diff. exit_epoch ;
587
587
}
588
588
if diff. withdrawable_epoch != Epoch :: new ( 0 ) {
589
- x . withdrawable_epoch = diff. withdrawable_epoch ;
589
+ v . withdrawable_epoch = diff. withdrawable_epoch ;
590
590
}
591
+ * x_arc = Arc :: new ( v) ;
591
592
} else {
592
593
xs. push ( Arc :: new ( diff) )
593
594
}
@@ -933,7 +934,6 @@ mod tests {
933
934
ys[ 5 ] = Arc :: new ( rand_validator ( & mut rng) ) ;
934
935
ys. push ( Arc :: new ( rand_validator ( & mut rng) ) ) ;
935
936
let diff = ValidatorsDiff :: compute ( & xs, & ys, config) . unwrap ( ) ;
936
-
937
937
let mut xs_out = xs. clone ( ) ;
938
938
diff. apply ( & mut xs_out, config) . unwrap ( ) ;
939
939
assert_eq ! ( xs_out, ys) ;
0 commit comments