@@ -503,19 +503,19 @@ where
503503
504504 let is_descendent_of = is_descendent_of ( & * self . client , None ) ;
505505
506- // TODO: add proper async support here
507- let best_header = futures :: executor :: block_on (
508- self . select_chain
509- . best_chain ( )
510- . map_err ( |e| Error :: Blockchain ( e . to_string ( ) ) ) ,
511- ) ? ;
506+ let ( best_block_hash , best_block_number ) = {
507+ // TODO [#9158]: Use SelectChain::best_chain() to get a potentially
508+ // more accurate best block
509+ let info = self . client . info ( ) ;
510+ ( info . best_hash , info . best_number )
511+ } ;
512512
513513 let authority_set = self . authority_set . inner ( ) ;
514514
515515 // block hash and number of the next pending authority set change in the
516516 // given best chain.
517517 let next_change = authority_set
518- . next_change ( & best_header . hash ( ) , & is_descendent_of)
518+ . next_change ( & best_block_hash , & is_descendent_of)
519519 . map_err ( |e| Error :: Safety ( e. to_string ( ) ) ) ?;
520520
521521 // find the hash of the latest block in the current set
@@ -528,7 +528,7 @@ where
528528 // the next set starts at `n` so the current one lasts until `n - 1`. if
529529 // `n` is later than the best block, then the current set is still live
530530 // at best block.
531- Some ( ( _, n) ) if n > * best_header . number ( ) => best_header . hash ( ) ,
531+ Some ( ( _, n) ) if n > best_block_number => best_block_hash ,
532532 Some ( ( h, _) ) => {
533533 // this is the header at which the new set will start
534534 let header = self . client . header ( BlockId :: Hash ( h) ) ?. expect (
@@ -541,7 +541,7 @@ where
541541 }
542542 // there is no pending change, the latest block for the current set is
543543 // the best block.
544- None => best_header . hash ( ) ,
544+ None => best_block_hash ,
545545 } ;
546546
547547 // generate key ownership proof at that block
@@ -570,7 +570,7 @@ where
570570 self . client
571571 . runtime_api ( )
572572 . submit_report_equivocation_unsigned_extrinsic (
573- & BlockId :: Hash ( best_header . hash ( ) ) ,
573+ & BlockId :: Hash ( best_block_hash ) ,
574574 equivocation_proof,
575575 key_owner_proof,
576576 )
0 commit comments