Implement filter processing feedback
MODIFY
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
@@ -116,7 +116,14 @@ namespace WalletWasabi.Gui.ViewModels
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ =>
{
- // ToDo: here monitor the status of the loading.
+ if (Global?.WalletService?.LastProcessedFilter?.Header?.Height is uint lastProcessedFilterHeight
+ && Global?.BitcoinStore?.SmartHeaderChain?.TipHeight is uint tipHeight)
+ {
+ var perc = tipHeight == 0 ?
+ 100
+ : ((decimal)lastProcessedFilterHeight / tipHeight * 100);
+ TryAddStatus(StatusType.WalletProcessingFilters, (ushort)perc);
+ }
}).DisposeWith(Disposables);
}
}
@@ -125,7 +132,7 @@ namespace WalletWasabi.Gui.ViewModels
walletCheckingInterwal?.Dispose();
walletCheckingInterwal = null;
- TryRemoveStatus(StatusType.WalletLoading);
+ TryRemoveStatus(StatusType.WalletLoading, StatusType.WalletProcessingFilters, StatusType.WalletProcessingTransactions);
}
})
.DisposeWith(Disposables);
@@ -145,21 +152,6 @@ namespace WalletWasabi.Gui.ViewModels
})
.DisposeWith(Disposables);
- Observable.FromEventPattern<bool>(typeof(WalletService), nameof(WalletService.InitializingFiltersChanged))
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(x =>
- {
- if (x.EventArgs)
- {
- TryAddStatus(StatusType.WalletProcessingFilters);
- }
- else
- {
- TryRemoveStatus(StatusType.WalletProcessingFilters);
- }
- })
- .DisposeWith(Disposables);
-
Synchronizer.WhenAnyValue(x => x.TorStatus)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(status => Tor = UseTor ? status : TorStatus.TurnedOff)
@@ -199,12 +191,12 @@ namespace WalletWasabi.Gui.ViewModels
.Subscribe(e => OnResponseArrivedIsGenSocksServFail(e.EventArgs))
.DisposeWith(Disposables);
- this.WhenAnyValue(x => x.FiltersLeft, x => x.DownloadingBlock, x => x.UseBitcoinCore, x => x.BitcoinCoreStatus)
+ this.WhenAnyValue(x => x.FiltersLeft, x => x.UseBitcoinCore, x => x.BitcoinCoreStatus)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(tup =>
{
- (int filtersLeft, bool downloadingBlock, bool useCore, RpcStatus coreStatus) = tup;
- if (filtersLeft == 0 && !downloadingBlock && (!useCore || coreStatus?.Synchronized is true))
+ (int filtersLeft, bool useCore, RpcStatus coreStatus) = tup;
+ if (filtersLeft == 0 && (!useCore || coreStatus?.Synchronized is true))
{
TryRemoveStatus(StatusType.Synchronizing);
}
@@ -386,11 +378,11 @@ namespace WalletWasabi.Gui.ViewModels
}
}
- public void TryAddStatus(StatusType status)
+ public void TryAddStatus(StatusType status, ushort percentage = 0)
{
try
{
- ActiveStatuses.Set(status);
+ ActiveStatuses.Set(new Status(status, percentage));
}
catch (Exception ex)
{

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -40,8 +40,6 @@ namespace WalletWasabi.Services
public static event EventHandler<bool> InitializingTransactionsChanged;
- public static event EventHandler<bool> InitializingFiltersChanged;
-
public BitcoinStore BitcoinStore { get; }
public KeyManager KeyManager { get; }
public WasabiSynchronizer Synchronizer { get; }
@@ -241,6 +239,8 @@ namespace WalletWasabi.Services
{
try
{
+ InitializingChanged?.Invoke(null, true);
+
if (!Synchronizer.IsRunning)
{
throw new NotSupportedException($"{nameof(Synchronizer)} is not running.");
@@ -282,9 +282,6 @@ namespace WalletWasabi.Services
InitializingTransactionsChanged?.Invoke(null, false);
}
- try
- {
- InitializingFiltersChanged?.Invoke(null, true);
// Go through the filters and queue to download the matches.
await BitcoinStore.IndexStore.ForeachFiltersAsync(async (filterModel) =>
{
@@ -295,11 +292,6 @@ namespace WalletWasabi.Services
},
new Height(bestKeyManagerHeight.Value + 1));
}
- finally
- {
- InitializingFiltersChanged?.Invoke(null, false);
- }
- }
private async Task LoadDummyMempoolAsync()
{
@@ -344,11 +336,8 @@ namespace WalletWasabi.Services
private async Task ProcessFilterModelAsync(FilterModel filterModel, CancellationToken cancel)
{
var matchFound = filterModel.Filter.MatchAny(KeyManager.GetPubKeyScriptBytes(), filterModel.FilterKey);
- if (!matchFound)
+ if (matchFound)
{
- return;
- }
-
Block currentBlock = await FetchBlockAsync(filterModel.Header.BlockHash, cancel); // Wait until not downloaded.
var height = new Height(filterModel.Header.Height);
@@ -364,6 +353,9 @@ namespace WalletWasabi.Services
NewBlockProcessed?.Invoke(this, currentBlock);
}
+ LastProcessedFilter = filterModel;
+ }
+
private Node _localBitcoinCoreNode = null;
public Node LocalBitcoinCoreNode
@@ -798,6 +790,7 @@ namespace WalletWasabi.Services
public bool IsDisposed => _disposedValue;
public CoreNode CoreNode { get; }
+ public FilterModel LastProcessedFilter { get; private set; }
protected virtual void Dispose(bool disposing)
{

Implement filter processing feedback