@@ -264,34 +264,31 @@ impl BitcoinIndexer {
264264 match net:: TcpStream :: connect ( ( self . config . peer_host . as_str ( ) , self . config . peer_port ) ) {
265265 Ok ( s) => {
266266 // Disable Nagle algorithm
267- s. set_nodelay ( true ) . map_err ( |_e | {
268- test_debug ! ( "Failed to set TCP_NODELAY: {:?}" , & _e ) ;
267+ s. set_nodelay ( true ) . map_err ( |e | {
268+ test_debug ! ( "Failed to set TCP_NODELAY: {e :?}" ) ;
269269 btc_error:: ConnectionError
270270 } ) ?;
271271
272272 // set timeout
273273 s. set_read_timeout ( Some ( Duration :: from_secs ( self . runtime . timeout ) ) )
274- . map_err ( |_e | {
275- test_debug ! ( "Failed to set TCP read timeout: {:?}" , & _e ) ;
274+ . map_err ( |e | {
275+ test_debug ! ( "Failed to set TCP read timeout: {e :?}" ) ;
276276 btc_error:: ConnectionError
277277 } ) ?;
278278
279279 s. set_write_timeout ( Some ( Duration :: from_secs ( self . runtime . timeout ) ) )
280- . map_err ( |_e | {
281- test_debug ! ( "Failed to set TCP write timeout: {:?}" , & _e ) ;
280+ . map_err ( |e | {
281+ test_debug ! ( "Failed to set TCP write timeout: {e :?}" ) ;
282282 btc_error:: ConnectionError
283283 } ) ?;
284284
285- if let Some ( s ) = self . runtime . sock . take ( ) {
286- let _ = s . shutdown ( Shutdown :: Both ) ;
285+ if let Some ( s_old ) = self . runtime . sock . replace ( s ) {
286+ let _ = s_old . shutdown ( Shutdown :: Both ) ;
287287 }
288-
289- self . runtime . sock = Some ( s) ;
290288 Ok ( ( ) )
291289 }
292290 Err ( _e) => {
293- let s = self . runtime . sock . take ( ) ;
294- if let Some ( s) = s {
291+ if let Some ( s) = self . runtime . sock . take ( ) {
295292 let _ = s. shutdown ( Shutdown :: Both ) ;
296293 }
297294 Err ( btc_error:: ConnectionError )
0 commit comments