Make sure cheater scan rpc capabilities

This commit is contained in:
nicolas.dorier 2021-10-11 17:49:04 +09:00
parent 601e17ed0f
commit 6c688b9684
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
2 changed files with 14 additions and 1 deletions

View File

@ -443,6 +443,7 @@ namespace BTCPayServer.Hosting
if (configuration.GetOrDefault<bool>("cheatmode", false))
{
services.AddSingleton<Cheater>();
services.AddSingleton<IHostedService, Cheater>(o => o.GetRequiredService<Cheater>());
}
return services;
}

View File

@ -1,15 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BTCPayServer.Configuration;
using BTCPayServer.Data;
using Microsoft.Extensions.Hosting;
using NBitcoin;
using NBitcoin.RPC;
namespace BTCPayServer.Services
{
public class Cheater
public class Cheater : IHostedService
{
private readonly ApplicationDbContextFactory _applicationDbContextFactory;
@ -35,5 +37,15 @@ namespace BTCPayServer.Services
await ctx.SaveChangesAsync().ConfigureAwait(false);
}
}
async Task IHostedService.StartAsync(CancellationToken cancellationToken)
{
await CashCow.ScanRPCCapabilitiesAsync();
}
Task IHostedService.StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
}