Skip to content

Commit

Permalink
No retries on withdrawals (#395)
Browse files Browse the repository at this point in the history
* No retries on withdrawals

* remove throw
  • Loading branch information
RodriFS committed Sep 9, 2024
1 parent a220b26 commit d87b071
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 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
2 changes: 1 addition & 1 deletion src/Services/BitcoinService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit d87b071

Please sign in to comment.