Remove coinreceived event (change to collectionchanged
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -6,6 +6,7 @@ using NBitcoin.Protocol.Behaviors;
using Org.BouncyCastle.Math;
using System;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -250,12 +251,14 @@ namespace WalletWasabi.Gui
Logger.LogInfo("WalletService started.");
}
CancelWalletServiceInitialization = null; // Must make it null explicitly, because dispose won't make it null.
- WalletService.CoinReceived += OnCoinReceived;
+ WalletService.Coins.CollectionChanged += Coins_CollectionChanged;
}
- private static void OnCoinReceived(object sender, SmartCoin coin)
+ private static void Coins_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
try
+ {
+ foreach (SmartCoin coin in e.NewItems)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
@@ -280,6 +283,7 @@ namespace WalletWasabi.Gui
// // It's harder than you'd think. Maybe the best would be to wait for .NET Core 3 for WPF things on Windows?
//}
}
+ }
catch (Exception ex)
{
Logger.LogWarning(ex, nameof(Global));
@@ -290,7 +294,7 @@ namespace WalletWasabi.Gui
{
if (WalletService != null)
{
- WalletService.CoinReceived -= OnCoinReceived;
+ WalletService.Coins.CollectionChanged -= Coins_CollectionChanged;
}
CancelWalletServiceInitialization?.Cancel();
CancelWalletServiceInitialization = null;

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -60,8 +60,6 @@ namespace WalletWasabi.Services
public event EventHandler<SmartCoin> CoinSpentOrSpenderConfirmed;
- public event EventHandler<SmartCoin> CoinReceived;
-
public event EventHandler<Block> NewBlockProcessed;
public Network Network => IndexDownloader.Network;
@@ -514,7 +512,6 @@ namespace WalletWasabi.Services
Coins.TryAdd(coin);
TransactionCache.TryAdd(tx);
- CoinReceived?.Invoke(this, coin);
}
else
{

Remove coinreceived event (change to collectionchanged