Ejemplo n.º 1
0
 public BitcoinDWaiters(
     AddressPoolServiceAccessor addressPool,
     NBXplorerNetworkProvider networkProvider,
     ChainProvider chains,
     RepositoryProvider repositoryProvider,
     ExplorerConfiguration config,
     RPCClientProvider rpcProvider,
     EventAggregator eventAggregator)
 {
     _Waiters = networkProvider
                .GetAll()
                .Select(s => (Repository: repositoryProvider.GetRepository(s),
                              RPCClient: rpcProvider.GetRPCClient(s),
                              Chain: chains.GetChain(s),
                              Network: s))
                .Where(s => s.Repository != null && s.RPCClient != null && s.Chain != null)
                .Select(s => new BitcoinDWaiter(s.RPCClient,
                                                config,
                                                networkProvider.GetFromCryptoCode(s.Network.CryptoCode),
                                                s.Chain,
                                                s.Repository,
                                                addressPool.Instance,
                                                eventAggregator))
                .ToDictionary(s => s.Network.CryptoCode, s => s);
     this.repositoryProvider = repositoryProvider;
 }
Ejemplo n.º 2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            await repositoryProvider.StartCompletion;

            _Waiters = networkProvider
                       .GetAll()
                       .Select(s => (Repository: repositoryProvider.GetRepository(s),
                                     RPCClient: rpcProvider.GetRPCClient(s),
                                     Chain: chains.GetChain(s),
                                     Network: s))
                       .Where(s => s.Repository != null && s.RPCClient != null && s.Chain != null)
                       .Select(s => new BitcoinDWaiter(s.RPCClient,
                                                       config,
                                                       networkProvider.GetFromCryptoCode(s.Network.CryptoCode),
                                                       s.Chain,
                                                       s.Repository,
                                                       addressPool,
                                                       eventAggregator))
                       .ToDictionary(s => s.Network.CryptoCode, s => s);
            await Task.WhenAll(_Waiters.Select(s => s.Value.StartAsync(cancellationToken)).ToArray());
        }