public StatusBarViewModel(NodesCollection nodes, MemPoolService memPoolService, IndexDownloader indexDownloader) { Nodes = nodes; Nodes.Added += Nodes_Added; Nodes.Removed += Nodes_Removed; Peers = Nodes.Count; MemPoolService = memPoolService; MemPoolService.TransactionReceived += MemPoolService_TransactionReceived; Mempool = MemPoolService.TransactionHashes.Count; IndexDownloader = indexDownloader; IndexDownloader.NewFilter += IndexDownloader_NewFilter; IndexDownloader.BestHeightChanged += IndexDownloader_BestHeightChanged; IndexDownloader.TorStatusChanged += IndexDownloader_TorStatusChanged; IndexDownloader.BackendStatusChanged += IndexDownloader_BackendStatusChanged; FiltersLeft = IndexDownloader.GetFiltersLeft(); this.WhenAnyValue(x => x.BlocksLeft).Subscribe(blocks => { SetStatus(); }); this.WhenAnyValue(x => x.FiltersLeft).Subscribe(filters => { SetStatus(); }); this.WhenAnyValue(x => x.Tor).Subscribe(tor => { SetStatus(); }); this.WhenAnyValue(x => x.Backend).Subscribe(backend => { SetStatus(); }); this.WhenAnyValue(x => x.Peers).Subscribe(peers => { SetStatus(); }); }
private void IndexDownloader_BestHeightChanged(object sender, Height e) { FiltersLeft = IndexDownloader.GetFiltersLeft(); }
private void IndexDownloader_NewFilter(object sender, Backend.Models.FilterModel e) { FiltersLeft = IndexDownloader.GetFiltersLeft(); }
public StatusBarViewModel(NodesCollection nodes, MemPoolService memPoolService, IndexDownloader indexDownloader, UpdateChecker updateChecker) { _clientOutOfDate = 0; _backendIncompatible = 0; Nodes = nodes; Nodes.Added += Nodes_Added; Nodes.Removed += Nodes_Removed; Peers = Nodes.Count; MemPoolService = memPoolService; MemPoolService.TransactionReceived += MemPoolService_TransactionReceived; Mempool = MemPoolService.TransactionHashes.Count; IndexDownloader = indexDownloader; UpdateChecker = updateChecker; IndexDownloader.NewFilter += IndexDownloader_NewFilter; IndexDownloader.BestHeightChanged += IndexDownloader_BestHeightChanged; IndexDownloader.TorStatusChanged += IndexDownloader_TorStatusChanged; IndexDownloader.BackendStatusChanged += IndexDownloader_BackendStatusChanged; FiltersLeft = IndexDownloader.GetFiltersLeft(); if (indexDownloader.Network == Network.Main) { ShowNetwork = ""; } else { ShowNetwork = indexDownloader.Network.ToString(); } this.WhenAnyValue(x => x.BlocksLeft).Subscribe(blocks => { SetStatusAndDoUpdateActions(); }); this.WhenAnyValue(x => x.FiltersLeft).Subscribe(filters => { SetStatusAndDoUpdateActions(); }); this.WhenAnyValue(x => x.Tor).Subscribe(tor => { SetStatusAndDoUpdateActions(); }); this.WhenAnyValue(x => x.Backend).Subscribe(backend => { SetStatusAndDoUpdateActions(); }); this.WhenAnyValue(x => x.Peers).Subscribe(peers => { SetStatusAndDoUpdateActions(); }); UpdateChecker.Start(TimeSpan.FromMinutes(7), () => { Interlocked.Exchange(ref _backendIncompatible, 1); SetStatusAndDoUpdateActions(); return(Task.CompletedTask); }, () => { Interlocked.Exchange(ref _clientOutOfDate, 1); SetStatusAndDoUpdateActions(); return(Task.CompletedTask); }); }