Skip to content

Commit

Permalink
Remove uncessary boolean and check if jsonRpc is already dispose to a…
Browse files Browse the repository at this point in the history
…void reconnect
  • Loading branch information
Apolixit committed Sep 14, 2024
1 parent 604048e commit 6f197fd
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions Substrate.NetApi/SubstrateClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public class SubstrateClient : IDisposable
/// <summary> The socket. </summary>
internal ClientWebSocket _socket;

/// <summary>
/// Check if the client has been disconnected manually (to avoid auto-reconnect)
/// </summary>
private bool _isDisconnectedManually = false;

/// <summary>
/// The "ping" to check the connection status
/// </summary>
Expand Down Expand Up @@ -388,11 +383,7 @@ private void OnJsonRpcDisconnected(object sender, JsonRpcDisconnectedEventArgs e
Logger.Error(e.Exception, $"JsonRpc disconnected: {e.Reason}");
OnConnectionLost();

if(_isDisconnectedManually)
{
_isDisconnectedManually = false;
return;
}
if (_jsonRpc == null || _jsonRpc.IsDisposed) return;

// Attempt to reconnect asynchronously
_ = Task.Run(async () =>
Expand Down Expand Up @@ -624,7 +615,6 @@ public async Task CloseAsync()
public async Task CloseAsync(CancellationToken token)
{
_connectTokenSource?.Cancel();
_isDisconnectedManually = true;

await Task.Run(async () =>
{
Expand Down

0 comments on commit 6f197fd

Please sign in to comment.