@@ -187,13 +187,7 @@ impl ConsensusEngine for Tendermint {
187
187
_ => {
188
188
let rewards = stake:: drain_previous_rewards ( block. state_mut ( ) ) ?;
189
189
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 ) ?;
197
191
198
192
if term > 1 {
199
193
let start_of_the_previous_term = {
@@ -273,7 +267,7 @@ impl ConsensusEngine for Tendermint {
273
267
274
268
let inner = self . inner . clone ( ) ;
275
269
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 ( ) ) ;
277
271
self . extension_initializer . send ( ( extension, client) ) . unwrap ( ) ;
278
272
279
273
let ( result, receiver) = crossbeam:: bounded ( 1 ) ;
@@ -317,13 +311,7 @@ impl ConsensusEngine for Tendermint {
317
311
}
318
312
319
313
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 ) ?;
327
315
let block_hash = match block_number {
328
316
None => {
329
317
client. block_header ( & BlockId :: Latest ) . expect ( "latest block must exist" ) . hash ( ) // the latest block
0 commit comments