@@ -187,13 +187,7 @@ impl ConsensusEngine for Tendermint {
187187 _ => {
188188 let rewards = stake:: drain_previous_rewards ( block. state_mut ( ) ) ?;
189189 let start_of_the_current_term = metadata. last_term_finished_block_num ( ) + 1 ;
190- let client = self
191- . client
192- . read ( )
193- . as_ref ( )
194- . ok_or ( EngineError :: CannotOpenBlock ) ?
195- . upgrade ( )
196- . ok_or ( EngineError :: CannotOpenBlock ) ?;
190+ let client = self . client ( ) . ok_or ( EngineError :: CannotOpenBlock ) ?;
197191
198192 if term > 1 {
199193 let start_of_the_previous_term = {
@@ -273,7 +267,7 @@ impl ConsensusEngine for Tendermint {
273267
274268 let inner = self . inner . clone ( ) ;
275269 let extension = service. register_extension ( move |api| TendermintExtension :: new ( inner, timeouts, api) ) ;
276- let client = Weak :: clone ( self . client . read ( ) . as_ref ( ) . unwrap ( ) ) ;
270+ let client = Arc :: downgrade ( & self . client ( ) . unwrap ( ) ) ;
277271 self . extension_initializer . send ( ( extension, client) ) . unwrap ( ) ;
278272
279273 let ( result, receiver) = crossbeam:: bounded ( 1 ) ;
@@ -317,13 +311,7 @@ impl ConsensusEngine for Tendermint {
317311 }
318312
319313 fn possible_authors ( & self , block_number : Option < u64 > ) -> Result < Option < Vec < Address > > , EngineError > {
320- let client = self
321- . client
322- . read ( )
323- . as_ref ( )
324- . ok_or ( EngineError :: CannotOpenBlock ) ?
325- . upgrade ( )
326- . ok_or ( EngineError :: CannotOpenBlock ) ?;
314+ let client = self . client ( ) . ok_or ( EngineError :: CannotOpenBlock ) ?;
327315 let block_hash = match block_number {
328316 None => {
329317 client. block_header ( & BlockId :: Latest ) . expect ( "latest block must exist" ) . hash ( ) // the latest block
0 commit comments