Skip to content

Commit

Permalink
bug: don't disconnect the connection we want to connect while version…
Browse files Browse the repository at this point in the history
… checking

when doing version checking, the connection isn't marked as maintained yet, this means flagging the not needed will disconnect it immediately.
a fix for this is to keep a state of `Connecting` for example to avoid disconnecting a connection which is in progress, eaiser solution is to not ask for disconnection for connections that we didn't force connect.
so only if we caused the connection to connect will we call for it to be not needed anymore
  • Loading branch information
mariocynicys committed Sep 16, 2024
1 parent 6b2713e commit c58da8f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mm2src/coins/utxo/rpc_clients/electrum_rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,14 @@ impl ElectrumClient {
let response = connection
.electrum_request(json, request.rpc_id(), ELECTRUM_REQUEST_TIMEOUT)
.await?;
// Inform the connection manager that the connection was queried and no longer needed now.
self.connection_manager.not_needed(&to_addr).await;
// If the request was not forcefully connected, we shouldn't inform the connection manager that it's
// not needed anymore, as we didn't force spawn it in the first place.
// This fixes dropping the connection after the version check request, as we don't mark the connection
// maintained till after the version is checked.
if force_connect {
// Inform the connection manager that the connection was queried and no longer needed now.
self.connection_manager.not_needed(&to_addr).await;
}

Ok(response)
}
Expand Down

0 comments on commit c58da8f

Please sign in to comment.