public PeerManagerProvider(
     INBXplorerClientProvider nbXplorerClientProvider,
     NRustLightningNetworkProvider networkProvider,
     IKeysRepository keysRepository,
     ILoggerFactory loggerFactory,
     ChannelProvider channelProvider,
     IOptions <Config> config
     )
 {
     foreach (var n in networkProvider.GetAll())
     {
         var nbx = nbXplorerClientProvider.TryGetClient(n);
         if (nbx != null)
         {
             var b      = new NbXplorerBroadcaster(nbx, loggerFactory.CreateLogger <NbXplorerBroadcaster>());
             var feeEst = new NbXplorerFeeEstimator(loggerFactory.CreateLogger <NbXplorerFeeEstimator>(),
                                                    channelProvider.GetFeeRateChannel(n).Reader);
             var chainWatchInterface =
                 new NbxChainWatchInterface(nbx, loggerFactory.CreateLogger <NbxChainWatchInterface>(), n);
             var peerManSeed = new byte[32];
             RandomUtils.GetBytes(peerManSeed);
             var logger          = new NativeLogger(loggerFactory.CreateLogger <NativeLogger>());
             var nbitcoinNetwork = n.NBitcoinNetwork;
             var conf            = config.Value.RustLightningConfig;
             var peerMan         = PeerManager.Create(peerManSeed.AsSpan(), nbitcoinNetwork, conf, chainWatchInterface, keysRepository, b,
                                                      logger, feeEst, 400000);
             _peerManagers.Add(n.CryptoCode, peerMan);
         }
     }
 }
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            foreach (var n in _networkProvider.GetAll())
            {
                var nbx = _nbXplorerClientProvider.TryGetClient(n);
                if (nbx != null)
                {
                    var b      = new NbXplorerBroadcaster(nbx, _loggerFactory.CreateLogger <NbXplorerBroadcaster>(), _eventAggregator);
                    var feeEst = new NbXplorerFeeEstimator(_loggerFactory.CreateLogger <NbXplorerFeeEstimator>(),
                                                           _channelProvider.GetFeeRateChannel(n).Reader);
                    var chainWatchInterface =
                        new NbxChainWatchInterface(nbx, _loggerFactory.CreateLogger <NbxChainWatchInterface>(), n);
                    var conf   = _config.Value.RustLightningConfig;
                    var logger = new NativeLogger(_loggerFactory.CreateLogger <NativeLogger>());
                    var repo   = _repositoryProvider.GetRepository(n);

                    uint currentBlockHeight;
                    int  tried0 = 0;
retry0:
                    try
                    {
                        currentBlockHeight = (uint)await nbx.RPCClient.GetBlockCountAsync();
                    }
                    catch when(tried0 < 4)
                    {
                        tried0++;
                        await Task.Delay(1000, cancellationToken);

                        goto retry0;
                    }