@@ -157,12 +157,15 @@ pub trait AuthorityDiscovery<Block: BlockT> {
157157 /// Retrieve authority identifiers of the current and next authority set.
158158 async fn authorities ( & self , at : Block :: Hash )
159159 -> std:: result:: Result < Vec < AuthorityId > , ApiError > ;
160+
161+ /// Retrieve best block hash
162+ async fn best_hash ( & self ) -> std:: result:: Result < Block :: Hash , Error > ;
160163}
161164
162165#[ async_trait:: async_trait]
163166impl < Block , T > AuthorityDiscovery < Block > for T
164167where
165- T : ProvideRuntimeApi < Block > + Send + Sync ,
168+ T : ProvideRuntimeApi < Block > + HeaderBackend < Block > + Send + Sync ,
166169 T :: Api : AuthorityDiscoveryApi < Block > ,
167170 Block : BlockT ,
168171{
@@ -172,13 +175,17 @@ where
172175 ) -> std:: result:: Result < Vec < AuthorityId > , ApiError > {
173176 self . runtime_api ( ) . authorities ( at)
174177 }
178+
179+ async fn best_hash ( & self ) -> std:: result:: Result < Block :: Hash , Error > {
180+ Ok ( self . info ( ) . best_hash )
181+ }
175182}
176183
177184impl < Client , Network , Block , DhtEventStream > Worker < Client , Network , Block , DhtEventStream >
178185where
179186 Block : BlockT + Unpin + ' static ,
180187 Network : NetworkProvider ,
181- Client : AuthorityDiscovery < Block > + HeaderBackend < Block > + ' static ,
188+ Client : AuthorityDiscovery < Block > + ' static ,
182189 DhtEventStream : Stream < Item = DhtEvent > + Unpin ,
183190{
184191 /// Construct a [`Worker`].
@@ -376,7 +383,7 @@ where
376383 }
377384
378385 async fn refill_pending_lookups_queue ( & mut self ) -> Result < ( ) > {
379- let best_hash = self . client . info ( ) . best_hash ;
386+ let best_hash = self . client . best_hash ( ) . await ? ;
380387
381388 let local_keys = match & self . role {
382389 Role :: PublishAndDiscover ( key_store) => key_store
@@ -594,7 +601,7 @@ where
594601 . into_iter ( )
595602 . collect :: < HashSet < _ > > ( ) ;
596603
597- let best_hash = client. info ( ) . best_hash ;
604+ let best_hash = client. best_hash ( ) . await ? ;
598605 let authorities = client
599606 . authorities ( best_hash)
600607 . await
0 commit comments