BobClient without being disposable.
MODIFY
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
@@ -612,9 +612,9 @@ namespace WalletWasabi.Tests.RegressionTests
throw new NotSupportedException("Coordinator did not sign the blinded output properly.");
}
- using (var bobClient1 = new BobClient(BaseUri, null))
- using (var bobClient2 = new BobClient(BaseUri, null))
{
+ var bobClient1 = new BobClient(BackendClearnetHttpClient);
+ var bobClient2 = new BobClient(BackendClearnetHttpClient);
await bobClient1.PostOutputAsync(aliceClient1.RoundId, new ActiveOutput(outputAddress1, connConfResp.activeOutputs.First().Signature, 0));
await bobClient2.PostOutputAsync(aliceClient2.RoundId, new ActiveOutput(outputAddress2, connConfResp2.activeOutputs.First().Signature, 0));
}
@@ -794,9 +794,9 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Equal(RoundPhase.OutputRegistration, roundState.Phase);
var l = 0;
+ var bobClient = new BobClient(BackendClearnetHttpClient);
+
foreach (var (aliceClient, outputs, _) in participants)
- {
- using (var bobClient = new BobClient(baseUri, null))
{
var i = 0;
foreach (var output in outputs.Take(activeOutputs[l].Count()))
@@ -804,7 +804,6 @@ namespace WalletWasabi.Tests.RegressionTests
await bobClient.PostOutputAsync(aliceClient.RoundId, new ActiveOutput(output.outputAddress, activeOutputs[l].ElementAt(i).Signature, i));
i++;
}
- }
l++;
}
@@ -988,17 +987,16 @@ namespace WalletWasabi.Tests.RegressionTests
users.Add((user.requester, user.blinded, user.activeOutputAddress, user.changeOutputAddress, user.inputProofModels, user.userInputData, user.aliceClient, resp.Item2.First().Signature));
}
- var outputRequests = new List<(BobClient, Task)>();
+ var outputRequests = new List<Task>();
foreach (var user in users)
{
- var bobClient = new BobClient(baseUri, null);
- outputRequests.Add((bobClient, bobClient.PostOutputAsync(roundId, new ActiveOutput(user.activeOutputAddress, user.unblindedSignature, 0))));
+ var bobClient = new BobClient(BackendClearnetHttpClient);
+ outputRequests.Add(bobClient.PostOutputAsync(roundId, new ActiveOutput(user.activeOutputAddress, user.unblindedSignature, 0)));
}
- foreach (var request in outputRequests)
+ foreach (Task task in outputRequests)
{
- await request.Item2;
- request.Item1?.Dispose();
+ await task;
}
var coinjoinRequests = new List<Task<Transaction>>();

MODIFY
WalletWasabi/CoinJoin/Client/Clients/BobClient.cs
WalletWasabi/CoinJoin/Client/Clients/BobClient.cs
-using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using WalletWasabi.CoinJoin.Common.Models;
using WalletWasabi.Helpers;
-using WalletWasabi.Tor.Http.Bases;
+using WalletWasabi.Tor.Http;
using WalletWasabi.Tor.Http.Extensions;
using WalletWasabi.WebClients.Wasabi;
namespace WalletWasabi.CoinJoin.Client.Clients
{
- public class BobClient : TorDisposableBase
+ public class BobClient
{
/// <inheritdoc/>
- public BobClient(Func<Uri> baseUriAction, EndPoint torSocks5EndPoint) : base(baseUriAction, torSocks5EndPoint)
+ public BobClient(IRelativeHttpClient httpClient)
{
+ HttpClient = httpClient;
}
- /// <inheritdoc/>
- public BobClient(Uri baseUri, EndPoint torSocks5EndPoint) : base(baseUri, torSocks5EndPoint)
- {
- }
+ private IRelativeHttpClient HttpClient { get; }
/// <returns>If the phase is still in OutputRegistration.</returns>
public async Task<bool> PostOutputAsync(long roundId, ActiveOutput activeOutput)
@@ -29,7 +26,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
Guard.NotNull(nameof(activeOutput), activeOutput);
var request = new OutputRequest { OutputAddress = activeOutput.Address, UnblindedSignature = activeOutput.Signature, Level = activeOutput.MixingLevel };
- using var response = await TorClient.SendAsync(HttpMethod.Post, $"/api/v{WasabiClient.ApiVersion}/btc/chaumiancoinjoin/output?roundId={roundId}", request.ToHttpStringContent()).ConfigureAwait(false);
+ using var response = await HttpClient.SendAsync(HttpMethod.Post, $"/api/v{WasabiClient.ApiVersion}/btc/chaumiancoinjoin/output?roundId={roundId}", request.ToHttpStringContent()).ConfigureAwait(false);
if (response.StatusCode == HttpStatusCode.Conflict)
{
return false;

MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
@@ -427,12 +427,15 @@ namespace WalletWasabi.CoinJoin.Client.Clients
shuffledOutputs.Shuffle();
foreach (var activeOutput in shuffledOutputs)
{
- using var bobClient = new BobClient(CcjHostUriAction, TorSocks5EndPoint);
+ using (TorHttpClient torHttpClient = Synchronizer.WasabiClientFactory.NewBackendTorHttpClient(isolateStream: true))
+ {
+ var bobClient = new BobClient(torHttpClient);
if (!await bobClient.PostOutputAsync(ongoingRound.RoundId, activeOutput).ConfigureAwait(false))
{
Logger.LogWarning($"Round ({ongoingRound.State.RoundId}) Bobs did not have enough time to post outputs before timeout. If you see this message, contact nopara73, so he can optimize the phase timeout periods to the worst Internet/Tor connections, which may be yours.");
break;
}
+ }
// Unblind our exposed links.
foreach (OutPoint input in registeredInputs)

BobClient without being disposable.