handle cancellation

This commit is contained in:
Kukks
2023-04-06 14:11:07 +02:00
parent 5ffd21d45a
commit 2a0165b5eb
3 changed files with 11 additions and 4 deletions

View File

@@ -11,7 +11,7 @@
<PropertyGroup> <PropertyGroup>
<Product>Nostr </Product> <Product>Nostr </Product>
<Description>Allows you to verify your nostr account with NIP5 and zap like the rest of the crazies</Description> <Description>Allows you to verify your nostr account with NIP5 and zap like the rest of the crazies</Description>
<Version>1.0.6</Version> <Version>1.0.7</Version>
</PropertyGroup> </PropertyGroup>
<!-- Plugin development properties --> <!-- Plugin development properties -->
<PropertyGroup> <PropertyGroup>

View File

@@ -74,7 +74,7 @@ public class LnurlDescriptionFilter : PluginHookFilter<string>
return arg; return arg;
} }
var entry = _memoryCache.CreateEntry(Nip05Plugin.GetZapRequestCacheKey(invoiceId.ToString())); using var entry = _memoryCache.CreateEntry(Nip05Plugin.GetZapRequestCacheKey(invoiceId.ToString()));
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5); entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5);
entry.SetAbsoluteExpiration(TimeSpan.FromMinutes(5)); entry.SetAbsoluteExpiration(TimeSpan.FromMinutes(5));
entry.SetValue(nostr); entry.SetValue(nostr);

View File

@@ -43,7 +43,6 @@ public class Zapper : IHostedService
{ {
while (!cancellationToken.IsCancellationRequested) while (!cancellationToken.IsCancellationRequested)
{ {
if (_pendingZapEvents.Any()) if (_pendingZapEvents.Any())
{ {
_logger.LogInformation($"Attempting to send {_pendingZapEvents.Count} zap receipts"); _logger.LogInformation($"Attempting to send {_pendingZapEvents.Count} zap receipts");
@@ -94,8 +93,16 @@ public class Zapper : IHostedService
} }
else else
{ {
try
{
await Task.Delay(100, waitingToken.Token); await Task.Delay(100, waitingToken.Token);
} }
catch (TaskCanceledException e)
{
break;
}
}
} }
} }
} }