Remove ITorHttpClient.SendAndRetryAsync.
See:
MODIFY
WalletWasabi.Tests/RegressionTests/BackendTests.cs
WalletWasabi.Tests/RegressionTests/BackendTests.cs
@@ -189,7 +189,7 @@ namespace WalletWasabi.Tests.RegressionTests
}
using var client = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint), null);
- var response = await client.TorClient.SendAndRetryAsync(HttpMethod.Get, request);
+ var response = await client.TorClient.SendAsync(HttpMethod.Get, request);
using (HttpContent content = response.Content)
{
var resp = await content.ReadAsJsonAsync<StatusResponse>();
@@ -202,7 +202,7 @@ namespace WalletWasabi.Tests.RegressionTests
await rpc.GenerateAsync(1);
- response = await client.TorClient.SendAndRetryAsync(HttpMethod.Get, request);
+ response = await client.TorClient.SendAsync(HttpMethod.Get, request);
using (HttpContent content = response.Content)
{
var resp = await content.ReadAsJsonAsync<StatusResponse>();
@@ -217,7 +217,7 @@ namespace WalletWasabi.Tests.RegressionTests
// Set back the time to trigger timeout in BlockchainController.GetStatusAsync.
global.IndexBuilderService.LastFilterBuildTime = DateTimeOffset.UtcNow - BlockchainController.FilterTimeout;
- response = await client.TorClient.SendAndRetryAsync(HttpMethod.Get, request);
+ response = await client.TorClient.SendAsync(HttpMethod.Get, request);
using (HttpContent content = response.Content)
{
var resp = await content.ReadAsJsonAsync<StatusResponse>();

MODIFY
WalletWasabi/Tor/Http/Interfaces/ITorHttpClient.cs
WalletWasabi/Tor/Http/Interfaces/ITorHttpClient.cs
@@ -15,37 +15,5 @@ namespace WalletWasabi.Tor.Http.Interfaces
bool IsTorUsed { get; }
Task<HttpResponseMessage> SendAsync(HttpMethod method, string relativeUri, HttpContent? content = null, CancellationToken cancel = default);
-
- /// <summary>
- /// Sends HTTP request (up to <paramref name="retry"/> times) to get HTTP response.
- /// </summary>
- /// <param name="retry">Maximum number of attempts to do to get HTTP response.</param>
- /// <exception cref="OperationCanceledException">When <paramref name="token"/> is used to cancel operation.</exception>
- public async Task<HttpResponseMessage?> SendAndRetryAsync(HttpMethod method, string relativeUri, int retry = 2, HttpContent? content = null, CancellationToken token = default)
- {
- HttpResponseMessage? response = null;
-
- while (retry-- > 0)
- {
- response?.Dispose();
- token.ThrowIfCancellationRequested();
- response = await SendAsync(method, relativeUri, content, cancel: token).ConfigureAwait(false);
-
- if (response.StatusCode == HttpStatusCode.OK)
- {
- break;
- }
-
- try
- {
- await Task.Delay(1000, token).ConfigureAwait(false);
- }
- catch (TaskCanceledException ex)
- {
- throw new OperationCanceledException(ex.Message, ex, token);
- }
- }
- return response;
- }
}
}

MODIFY
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
WalletWasabi/WebClients/Wasabi/WasabiClient.cs
@@ -56,12 +56,7 @@ namespace WalletWasabi.WebClients.Wasabi
relativeUri = $"{relativeUri}&estimateSmartFeeMode={estimateMode}";
}
- using HttpResponseMessage? response = await TorClient.SendAndRetryAsync(HttpMethod.Get, relativeUri, token: cancel).ConfigureAwait(false);
-
- if (response is null)
- {
- throw new HttpRequestException("No HTTP response received.");
- }
+ using HttpResponseMessage response = await TorClient.SendAsync(HttpMethod.Get, relativeUri, cancel: cancel).ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -83,15 +78,10 @@ namespace WalletWasabi.WebClients.Wasabi
/// </remarks>
public async Task<FiltersResponse?> GetFiltersAsync(uint256 bestKnownBlockHash, int count, CancellationToken cancel = default)
{
- using HttpResponseMessage? response = await TorClient.SendAndRetryAsync(
+ using HttpResponseMessage response = await TorClient.SendAsync(
HttpMethod.Get,
$"/api/v{ApiVersion}/btc/blockchain/filters?bestKnownBlockHash={bestKnownBlockHash}&count={count}",
- token: cancel).ConfigureAwait(false);
-
- if (response is null)
- {
- throw new HttpRequestException("No HTTP response received.");
- }
+ cancel: cancel).ConfigureAwait(false);
if (response.StatusCode == HttpStatusCode.NoContent)
{
@@ -124,15 +114,10 @@ namespace WalletWasabi.WebClients.Wasabi
{
cancel.ThrowIfCancellationRequested();
- using HttpResponseMessage? response = await TorClient.SendAndRetryAsync(
+ using HttpResponseMessage response = await TorClient.SendAsync(
HttpMethod.Get,
$"/api/v{ApiVersion}/btc/blockchain/transaction-hexes?&transactionIds={string.Join("&transactionIds=", chunk.Select(x => x.ToString()))}",
- token: cancel).ConfigureAwait(false);
-
- if (response is null)
- {
- throw new HttpRequestException("No HTTP response received.");
- }
+ cancel: cancel).ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -188,15 +173,10 @@ namespace WalletWasabi.WebClients.Wasabi
public async Task<IEnumerable<uint256>> GetMempoolHashesAsync(CancellationToken cancel = default)
{
- using HttpResponseMessage? response = await TorClient.SendAndRetryAsync(
+ using HttpResponseMessage response = await TorClient.SendAsync(
HttpMethod.Get,
$"/api/v{ApiVersion}/btc/blockchain/mempool-hashes",
- token: cancel).ConfigureAwait(false);
-
- if (response is null)
- {
- throw new HttpRequestException("No HTTP response received.");
- }
+ cancel: cancel).ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -216,15 +196,10 @@ namespace WalletWasabi.WebClients.Wasabi
/// <param name="compactness">1 to 64</param>
public async Task<ISet<string>> GetMempoolHashesAsync(int compactness, CancellationToken cancel = default)
{
- using HttpResponseMessage? response = await TorClient.SendAndRetryAsync(
+ using HttpResponseMessage response = await TorClient.SendAsync(
HttpMethod.Get,
$"/api/v{ApiVersion}/btc/blockchain/mempool-hashes?compactness={compactness}",
- token: cancel).ConfigureAwait(false);
-
- if (response is null)
- {
- throw new HttpRequestException("No HTTP response received.");
- }
+ cancel: cancel).ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -243,12 +218,7 @@ namespace WalletWasabi.WebClients.Wasabi
public async Task<IEnumerable<ExchangeRate>> GetExchangeRatesAsync()
{
- using HttpResponseMessage? response = await TorClient.SendAndRetryAsync(HttpMethod.Get, $"/api/v{ApiVersion}/btc/offchain/exchange-rates").ConfigureAwait(false);
-
- if (response is null)
- {
- throw new HttpRequestException("No HTTP response received.");
- }
+ using HttpResponseMessage response = await TorClient.SendAsync(HttpMethod.Get, $"/api/v{ApiVersion}/btc/offchain/exchange-rates").ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -267,12 +237,7 @@ namespace WalletWasabi.WebClients.Wasabi
public async Task<(Version ClientVersion, ushort BackendMajorVersion, Version LegalDocumentsVersion)> GetVersionsAsync(CancellationToken cancel)
{
- using HttpResponseMessage? response = await TorClient.SendAndRetryAsync(HttpMethod.Get, "/api/software/versions", token: cancel).ConfigureAwait(false);
-
- if (response is null)
- {
- throw new HttpRequestException("No HTTP response received.");
- }
+ using HttpResponseMessage response = await TorClient.SendAsync(HttpMethod.Get, "/api/software/versions", cancel: cancel).ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{
@@ -307,15 +272,10 @@ namespace WalletWasabi.WebClients.Wasabi
public async Task<string> GetLegalDocumentsAsync(CancellationToken cancel)
{
- using HttpResponseMessage? response = await TorClient.SendAndRetryAsync(
+ using HttpResponseMessage response = await TorClient.SendAsync(
HttpMethod.Get,
$"/api/v{ApiVersion}/wasabi/legaldocuments",
- token: cancel).ConfigureAwait(false);
-
- if (response is null)
- {
- throw new HttpRequestException("No HTTP response received.");
- }
+ cancel: cancel).ConfigureAwait(false);
if (response.StatusCode != HttpStatusCode.OK)
{

Remove ITorHttpClient.SendAndRetryAsync.

See: https://github.com/zkSNACKs/WalletWasabi/pull/4642#discussion_r518130537