@@ -474,12 +474,12 @@ impl State {
474474 context : & Arc < Context < Message > > ,
475475 delegators : & [ ( & StakeAddress , & DRepChoice ) ] ,
476476 ) -> Result < ( ) > {
477- let mut stake_address_to_input = HashMap :: with_capacity ( delegators. len ( ) ) ;
477+ let mut stake_address_to_drep = HashMap :: with_capacity ( delegators. len ( ) ) ;
478478 let mut stake_addresses = Vec :: with_capacity ( delegators. len ( ) ) ;
479479
480480 for & ( stake_address, drep) in delegators {
481481 stake_addresses. push ( stake_address. clone ( ) ) ;
482- stake_address_to_input . insert ( stake_address, ( stake_address , drep) ) ;
482+ stake_address_to_drep . insert ( stake_address, drep) ;
483483 }
484484
485485 let msg = Arc :: new ( Message :: StateQuery ( StateQuery :: Accounts (
@@ -501,8 +501,8 @@ impl State {
501501 } ;
502502
503503 for ( stake_address, old_drep_opt) in result_map {
504- let & ( delegator , new_drep_choice) = match stake_address_to_input . get ( & stake_address) {
505- Some ( pair ) => pair ,
504+ let new_drep_choice = match stake_address_to_drep . get ( & stake_address) {
505+ Some ( & drep ) => drep ,
506506 None => continue ,
507507 } ;
508508
@@ -516,10 +516,7 @@ impl State {
516516 if old_drep_cred != new_drep_cred {
517517 self . update_historical ( & old_drep_cred, false , |entry| {
518518 if let Some ( delegators) = entry. delegators . as_mut ( ) {
519- delegators. retain ( |s| {
520- s. get_credential ( ) . get_hash ( )
521- != delegator. get_credential ( ) . get_hash ( )
522- } ) ;
519+ delegators. retain ( |s| s. get_hash ( ) != stake_address. get_hash ( ) ) ;
523520 }
524521 } ) ?;
525522 }
@@ -529,8 +526,8 @@ impl State {
529526 // Add delegator to new DRep
530527 match self . update_historical ( & new_drep_cred, true , |entry| {
531528 if let Some ( delegators) = entry. delegators . as_mut ( ) {
532- if !delegators. contains ( delegator ) {
533- delegators. push ( delegator . clone ( ) ) ;
529+ if !delegators. contains ( & stake_address ) {
530+ delegators. push ( stake_address . clone ( ) ) ;
534531 }
535532 }
536533 } ) {
0 commit comments