Skip to content

Commit

Permalink
No retries on withdrawals
Browse files Browse the repository at this point in the history
  • Loading branch information
RodriFS committed Sep 9, 2024
1 parent a220b26 commit f386544
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
15 changes: 15 additions & 0 deletions src/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
},
]
}
18 changes: 8 additions & 10 deletions src/Jobs/PerformWithdrawalJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/Services/BitcoinService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f386544

Please sign in to comment.