From f386544537e7e0e9fddfbdff17181f9fec6d6886 Mon Sep 17 00:00:00 2001 From: Rodrigo <39995243+RodriFS@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:08:33 +0200 Subject: [PATCH] No retries on withdrawals --- src/.vscode/launch.json | 15 +++++++++++++++ src/Jobs/PerformWithdrawalJob.cs | 18 ++++++++---------- src/Services/BitcoinService.cs | 1 + 3 files changed, 24 insertions(+), 10 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..2c297f01 100644 --- a/src/Services/BitcoinService.cs +++ b/src/Services/BitcoinService.cs @@ -404,6 +404,7 @@ public async Task PerformWithdrawal(WalletWithdrawalRequest walletWithdrawalRequ if (transactionCheckResult != TransactionCheckResult.Success) { _logger.LogError("Invalid tx check reason: {Reason}", transactionCheckResult.Humanize()); + throw new InvalidOperationException($"Invalid tx check reason: {transactionCheckResult.Humanize()}"); } var node = (await _nodeRepository.GetAllManagedByNodeGuard()).FirstOrDefault();