@@ -503,19 +503,19 @@ where
503
503
504
504
let is_descendent_of = is_descendent_of ( & * self . client , None ) ;
505
505
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
+ } ;
512
512
513
513
let authority_set = self . authority_set . inner ( ) ;
514
514
515
515
// block hash and number of the next pending authority set change in the
516
516
// given best chain.
517
517
let next_change = authority_set
518
- . next_change ( & best_header . hash ( ) , & is_descendent_of)
518
+ . next_change ( & best_block_hash , & is_descendent_of)
519
519
. map_err ( |e| Error :: Safety ( e. to_string ( ) ) ) ?;
520
520
521
521
// find the hash of the latest block in the current set
@@ -528,7 +528,7 @@ where
528
528
// the next set starts at `n` so the current one lasts until `n - 1`. if
529
529
// `n` is later than the best block, then the current set is still live
530
530
// 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 ,
532
532
Some ( ( h, _) ) => {
533
533
// this is the header at which the new set will start
534
534
let header = self . client . header ( BlockId :: Hash ( h) ) ?. expect (
@@ -541,7 +541,7 @@ where
541
541
}
542
542
// there is no pending change, the latest block for the current set is
543
543
// the best block.
544
- None => best_header . hash ( ) ,
544
+ None => best_block_hash ,
545
545
} ;
546
546
547
547
// generate key ownership proof at that block
@@ -570,7 +570,7 @@ where
570
570
self . client
571
571
. runtime_api ( )
572
572
. submit_report_equivocation_unsigned_extrinsic (
573
- & BlockId :: Hash ( best_header . hash ( ) ) ,
573
+ & BlockId :: Hash ( best_block_hash ) ,
574
574
equivocation_proof,
575
575
key_owner_proof,
576
576
)
0 commit comments