Have only DisconnectAsync
MODIFY
WalletWasabi/BitcoinCore/P2pNode.cs
WalletWasabi/BitcoinCore/P2pNode.cs
@@ -146,14 +146,16 @@ namespace WalletWasabi.BitcoinCore
/// <summary>
/// It is not equivalent to Dispose, but it is being called from Dispose.
/// </summary>
- public async Task DisconnectAsync(CancellationToken cancel)
+ public async Task<bool> DisconnectAsync(CancellationToken cancel)
{
var node = Node;
if (node is null)
{
- return;
+ return true;
}
+ try
+ {
lock (SubscriptionLock)
{
MempoolService.TrustedNodeMode = false;
@@ -170,16 +172,6 @@ namespace WalletWasabi.BitcoinCore
}
}
- await TryDisconnectNodeAsync(node, cancel).ConfigureAwait(false);
-
- Node = null;
- Logger.LogInfo("P2p Bitcoin node is disconnected.");
- }
-
- private async Task<bool> TryDisconnectNodeAsync(Node node, CancellationToken cancel)
- {
- try
- {
// Disconnection not waited here.
node.DisconnectAsync();
@@ -192,14 +184,19 @@ namespace WalletWasabi.BitcoinCore
throw new TimeoutException("Could not disconnect P2p Bitcoin node");
}
}
+
+ Logger.LogInfo("P2p Bitcoin node is disconnected.");
+ return true;
}
catch (Exception ex)
{
- Logger.LogDebug(ex);
+ Logger.LogError($"P2p Bitcoin node failed to disconnect. '{ex.ToUserFriendlyString()}'");
return false;
}
-
- return true;
+ finally
+ {
+ Node = null;
+ }
}
}
}

Have only DisconnectAsync