From d87b0719b8feba1469c2b0f2758fd8a5646944f4 Mon Sep 17 00:00:00 2001 From: Rodrigo <39995243+RodriFS@users.noreply.github.com> Date: Mon, 9 Sep 2024 13:45:28 +0200 Subject: [PATCH] No retries on withdrawals (#395) * No retries on withdrawals * remove throw --- src/.vscode/launch.json | 15 +++++++++++++++ src/Jobs/PerformWithdrawalJob.cs | 18 ++++++++---------- src/Services/BitcoinService.cs | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 src/.vscode/launch.json diff --git a/src/.vscode/launch.json b/src/.vscode/launch.json new file mode 100644 index 00000000..f2ca35ad --- /dev/null +++ b/src/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "program": "${workspaceFolder}/bin/Debug/net8.0/NodeGuard.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "console": "internalConsole" + }, + ] +} \ No newline at end of file diff --git a/src/Jobs/PerformWithdrawalJob.cs b/src/Jobs/PerformWithdrawalJob.cs index 3a71964a..93cd9dcb 100644 --- a/src/Jobs/PerformWithdrawalJob.cs +++ b/src/Jobs/PerformWithdrawalJob.cs @@ -52,20 +52,18 @@ public async Task Execute(IJobExecutionContext context) var withdrawalRequestId = data.GetInt("withdrawalRequestId"); try { - await RetriableJob.Execute(context, async () => - { - var withdrawalRequest = await _walletWithdrawalRequestRepository.GetById(withdrawalRequestId); - await _bitcoinService.PerformWithdrawal(withdrawalRequest); - }); + var withdrawalRequest = await _walletWithdrawalRequestRepository.GetById(withdrawalRequestId); + await _bitcoinService.PerformWithdrawal(withdrawalRequest!); } catch (Exception e) { - await RetriableJob.OnFail(context, async () => + var request = await _walletWithdrawalRequestRepository.GetById(withdrawalRequestId); + request!.Status = WalletWithdrawalRequestStatus.Failed; + var (updated, _) = _walletWithdrawalRequestRepository.Update(request); + if (!updated) { - var request = await _walletWithdrawalRequestRepository.GetById(withdrawalRequestId); - request.Status = WalletWithdrawalRequestStatus.Failed; - _walletWithdrawalRequestRepository.Update(request); - }); + _logger.LogError("Failed to update withdrawal request status to failed"); + } _logger.LogError(e, "Error on {JobName}", nameof(PerformWithdrawalJob)); throw new JobExecutionException(e, false); diff --git a/src/Services/BitcoinService.cs b/src/Services/BitcoinService.cs index e67ab73a..8dbee02f 100644 --- a/src/Services/BitcoinService.cs +++ b/src/Services/BitcoinService.cs @@ -452,7 +452,7 @@ public async Task PerformWithdrawal(WalletWithdrawalRequest walletWithdrawalRequ walletWithdrawalRequest.DestinationAddress, CurrentNetworkHelper.GetCurrentNetwork())); - await _nbXplorerService.TrackAsync(trackedSourceAddress, new TrackWalletRequest{}, default); + await _nbXplorerService.TrackAsync(trackedSourceAddress, new TrackWalletRequest { }, default); } catch (Exception e) {