コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
        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;
                    }
コード例 #3
0
        public TestPeerManagerProvider(IBroadcaster broadcaster, IFeeEstimator feeEstimator, IChainWatchInterface chainWatchInterface, IOptions <Config> config, ILoggerFactory loggerFactory, IKeysRepository keysRepository)
        {
            _broadcaster         = broadcaster;
            _feeEstimator        = feeEstimator;
            _chainWatchInterface = chainWatchInterface;
            var seed          = new byte[32];
            var n             = NBitcoin.Network.RegTest;
            var conf          = config.Value.RustLightningConfig;
            var logger        = new NativeLogger(loggerFactory.CreateLogger <NativeLogger>());
            var keysInterface = new KeysManager(seed, DateTime.UnixEpoch);

            _peerManager =
                PeerManager.Create(seed.AsSpan(), n, conf, chainWatchInterface, keysInterface, broadcaster, logger, feeEstimator, 100);
        }
コード例 #4
0
 void Start()
 {
     NativeLogger.TestLogger();
 }