Only the mempool classes need the TransactionHashes
MODIFY
WalletWasabi.Tests/UnitTests/TransactionProcessorTests.cs
WalletWasabi.Tests/UnitTests/TransactionProcessorTests.cs
@@ -61,14 +61,12 @@ namespace WalletWasabi.Tests.UnitTests
// No segwit transaction. Ignore it.
var tx = CreateCreditingTransaction(new Key().PubKey.Hash.ScriptPubKey, Money.Coins(1.0m), isConfirmed: true);
- transactionProcessor.TransactionHashes.Append(tx.GetHash()); // This transaction was already seen before
var relevant = transactionProcessor.Process(tx);
Assert.False(relevant);
Assert.Empty(transactionProcessor.Coins);
Assert.Empty(transactionProcessor.TransactionCache);
- Assert.Empty(transactionProcessor.TransactionHashes);
}
[Fact]
@@ -80,7 +78,6 @@ namespace WalletWasabi.Tests.UnitTests
var key = transactionProcessor.KeyManager.GetKeys().First();
var tx = CreateCreditingTransaction(key.PubKey.WitHash.ScriptPubKey, Money.Coins(1.0m));
- transactionProcessor.TransactionHashes.Append(tx.GetHash()); // This transaction was already seen before
transactionProcessor.Process(tx);
var cachedTx = Assert.Single(transactionProcessor.TransactionCache);
@@ -99,8 +96,6 @@ namespace WalletWasabi.Tests.UnitTests
Assert.NotEqual(Height.Mempool, cachedTx.Height);
coin = Assert.Single(transactionProcessor.Coins);
Assert.Equal(blockHeight, coin.Height);
-
- Assert.Empty(transactionProcessor.TransactionHashes);
}
[Fact]
@@ -127,7 +122,6 @@ namespace WalletWasabi.Tests.UnitTests
Assert.Single(transactionProcessor.Coins, coin => coin.Unspent);
Assert.Single(transactionProcessor.Coins, coin => !coin.Unspent);
Assert.Equal(2, transactionProcessor.TransactionCache.Count());
- Assert.Empty(transactionProcessor.TransactionHashes);
}
[Fact]
@@ -153,7 +147,6 @@ namespace WalletWasabi.Tests.UnitTests
Assert.True(relevant);
Assert.Single(transactionProcessor.Coins, coin => coin.Unspent && coin.Confirmed);
Assert.Single(transactionProcessor.Coins, coin => !coin.Unspent && coin.Confirmed);
- Assert.Empty(transactionProcessor.TransactionHashes);
}
[Fact]
@@ -182,7 +175,6 @@ namespace WalletWasabi.Tests.UnitTests
Assert.True(relevant);
Assert.Single(transactionProcessor.Coins, coin => coin.Unspent && coin.Amount == Money.Coins(0.9m) && coin.IsReplaceable);
Assert.Single(transactionProcessor.Coins, coin => !coin.Unspent && coin.Amount == Money.Coins(1.0m) && !coin.IsReplaceable);
- Assert.Empty(transactionProcessor.TransactionHashes);
}
[Fact]
@@ -305,7 +297,6 @@ namespace WalletWasabi.Tests.UnitTests
keyManager.AssertCleanKeysIndexed();
return new TransactionProcessor(
keyManager,
- new ConcurrentHashSet<uint256>(),
new ObservableConcurrentHashSet<SmartCoin>(),
Money.Coins(0.0001m),
new ConcurrentHashSet<SmartTransaction>());

MODIFY
WalletWasabi/Services/TransactionProcessor.cs
WalletWasabi/Services/TransactionProcessor.cs
@@ -13,7 +13,6 @@ namespace WalletWasabi.Services
public ConcurrentHashSet<SmartTransaction> TransactionCache { get; }
public KeyManager KeyManager { get; }
- public ConcurrentHashSet<uint256> TransactionHashes { get; }
public ObservableConcurrentHashSet<SmartCoin> Coins { get; }
public Money DustThreshold { get; }
@@ -25,13 +24,11 @@ namespace WalletWasabi.Services
public event EventHandler<SmartCoin> CoinReceived;
public TransactionProcessor(KeyManager keyManager,
- ConcurrentHashSet<uint256> transactionHashes,
ObservableConcurrentHashSet<SmartCoin> coins,
Money dustThreshold,
ConcurrentHashSet<SmartTransaction> transactionCache)
{
KeyManager = Guard.NotNull(nameof(keyManager), keyManager);
- TransactionHashes = Guard.NotNull(nameof(transactionHashes), transactionHashes);
Coins = Guard.NotNull(nameof(coins), coins);
DustThreshold = Guard.NotNull(nameof(dustThreshold), dustThreshold);
TransactionCache = Guard.NotNull(nameof(transactionCache), transactionCache);
@@ -45,7 +42,6 @@ namespace WalletWasabi.Services
bool justUpdate = false;
if (tx.Confirmed)
{
- TransactionHashes.TryRemove(txId); // If we have in mempool, remove.
if (!tx.Transaction.PossiblyP2WPKHInvolved())
{
return false; // We do not care about non-witness transactions for other than mempool cleanup.

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -119,7 +119,7 @@ namespace WalletWasabi.Services
TransactionCache = new ConcurrentHashSet<SmartTransaction>();
- TransactionProcessor = new TransactionProcessor(KeyManager, Mempool.TransactionHashes, Coins, ServiceConfiguration.DustThreshold, TransactionCache);
+ TransactionProcessor = new TransactionProcessor(KeyManager, Coins, ServiceConfiguration.DustThreshold, TransactionCache);
TransactionProcessor.CoinSpent += TransactionProcessor_CoinSpent;
TransactionProcessor.CoinReceived += TransactionProcessor_CoinReceivedAsync;
@@ -198,7 +198,6 @@ namespace WalletWasabi.Services
}
}
- Mempool.TransactionHashes.TryRemove(toRemove.TransactionId);
var txToRemove = TryGetTxFromCache(toRemove.TransactionId);
if (txToRemove != default(SmartTransaction))
{
@@ -384,7 +383,6 @@ namespace WalletWasabi.Services
{
tx.SetHeight(Height.Mempool);
await ProcessTransactionAsync(tx);
- Mempool.TransactionHashes.TryAdd(tx.GetHash());
Logger.LogInfo($"Transaction was successfully tested against the backend's mempool hashes: {tx.GetHash()}.");
count++;
@@ -404,7 +402,6 @@ namespace WalletWasabi.Services
{
tx.SetHeight(Height.Mempool);
await ProcessTransactionAsync(tx);
- Mempool.TransactionHashes.TryAdd(tx.GetHash());
}
Logger.LogWarning(ex);
@@ -1295,8 +1292,6 @@ namespace WalletWasabi.Services
{
SerializeTransactionCache();
}
-
- Mempool.TransactionHashes.TryAdd(transaction.GetHash());
}
Logger.LogInfo($"Transaction is successfully broadcasted to backend: {transaction.GetHash()}.");

Only the mempool classes need the TransactionHashes