< Summary - Combined Code Coverage

Information
Class: NLightning.Node.Services.NltgDaemonService
Assembly: NLightning.Node
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Node/Services/NltgDaemonService.cs
Tag: 36_15743069263
Line coverage
0%
Covered lines: 0
Uncovered lines: 34
Coverable lines: 34
Total lines: 79
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
ExecuteAsync()0%110100%
StopAsync()100%210%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Node/Services/NltgDaemonService.cs

#LineLine coverage
 1using Microsoft.Extensions.Configuration;
 2using Microsoft.Extensions.Hosting;
 3using Microsoft.Extensions.Logging;
 4using Microsoft.Extensions.Options;
 5
 6namespace NLightning.Node.Services;
 7
 8using Domain.Bitcoin.Interfaces;
 9using Domain.Node.Interfaces;
 10using Domain.Node.Options;
 11using Domain.Protocol.Interfaces;
 12using Infrastructure.Bitcoin.Wallet.Interfaces;
 13
 14public class NltgDaemonService : BackgroundService
 15{
 16    private readonly IBlockchainMonitor _blockchainMonitor;
 17    private readonly IConfiguration _configuration;
 18    private readonly IFeeService _feeService;
 19    private readonly ILogger<NltgDaemonService> _logger;
 20    private readonly IPeerManager _peerManager;
 21    private readonly NodeOptions _nodeOptions;
 22    private readonly ISecureKeyManager _secureKeyManager;
 23
 024    public NltgDaemonService(IBlockchainMonitor blockchainMonitor, IConfiguration configuration, IFeeService feeService,
 025                             ILogger<NltgDaemonService> logger, IOptions<NodeOptions> nodeOptions,
 026                             IPeerManager peerManager, ISecureKeyManager secureKeyManager)
 27    {
 028        _blockchainMonitor = blockchainMonitor;
 029        _configuration = configuration;
 030        _feeService = feeService;
 031        _logger = logger;
 032        _peerManager = peerManager;
 033        _nodeOptions = nodeOptions.Value;
 034        _secureKeyManager = secureKeyManager;
 035    }
 36
 37    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 38    {
 039        var network = _configuration["network"] ?? _configuration["n"] ?? _nodeOptions.BitcoinNetwork;
 040        var isDaemon = _configuration.GetValue<bool?>("daemon")
 041                    ?? _configuration.GetValue<bool?>("daemon-child")
 042                    ?? _nodeOptions.Daemon;
 43
 044        _logger.LogInformation("NLTG Daemon started on {Network} network", network);
 045        _logger.LogDebug("Running in daemon mode: {IsDaemon}", isDaemon);
 46
 047        var pubKey = _secureKeyManager.GetNodePubKey();
 048        _logger.LogDebug("lncli connect {pubKey}@docker.for.mac.host.internal:9735", pubKey.ToString());
 49
 50        try
 51        {
 52            // Start the fee service
 053            await _feeService.StartAsync(stoppingToken);
 54
 55            // Start the peer manager service
 056            await _peerManager.StartAsync(stoppingToken);
 57
 58            // Start the blockchain monitor service
 059            await _blockchainMonitor.StartAsync(stoppingToken);
 60
 061            while (!stoppingToken.IsCancellationRequested)
 062                await Task.Delay(1000, stoppingToken);
 063        }
 064        catch (OperationCanceledException)
 65        {
 066            _logger.LogInformation("Stopping NLTG daemon service");
 067        }
 068    }
 69
 70    public override async Task StopAsync(CancellationToken cancellationToken)
 71    {
 072        _logger.LogInformation("NLTG shutdown requested");
 73
 074        await Task.WhenAll(_blockchainMonitor.StopAsync(), _feeService.StopAsync(), _peerManager.StopAsync(),
 075                           base.StopAsync(cancellationToken));
 76
 077        _logger.LogInformation("NLTG daemon service stopped");
 078    }
 79}