Make stx update tryupdate
MODIFY
WalletWasabi/Models/SmartTransaction.cs
WalletWasabi/Models/SmartTransaction.cs
@@ -94,8 +94,9 @@ namespace WalletWasabi.Models
/// <summary>
/// Update the transaction with the data acquired from another transaction. (For example merge their labels.)
/// </summary>
- public void Update(SmartTransaction tx)
+ public bool TryUpdate(SmartTransaction tx)
{
+ var updated = false;
// If this is not the same tx, then don't update.
if (this != tx)
{
@@ -104,23 +105,39 @@ namespace WalletWasabi.Models
// Set the height related properties, only if confirmed.
if (tx.Confirmed)
+ {
+ if (Height != tx.Height)
{
Height = tx.Height;
+ updated = true;
+ }
+ if (BlockHash != tx.BlockHash)
+ {
BlockHash = tx.BlockHash;
+ updated = true;
+ }
+ if (BlockIndex != tx.BlockIndex)
+ {
BlockIndex = tx.BlockIndex;
+ updated = true;
+ }
}
// Always the earlier seen is the firstSeen.
if (tx.FirstSeen < FirstSeen)
{
FirstSeen = tx.FirstSeen;
+ updated = true;
}
// Merge labels.
if (Label != tx.Label)
{
Label = SmartLabel.Merge(Label, tx.Label);
+ updated = true;
}
+
+ return updated;
}
public void SetReplacement()

MODIFY
WalletWasabi/Transactions/AllTransactionStore.cs
WalletWasabi/Transactions/AllTransactionStore.cs
@@ -118,7 +118,7 @@ namespace WalletWasabi.Transactions
{
if (MempoolStore.TryRemove(hash, out SmartTransaction found))
{
- found.Update(tx);
+ found.TryUpdate(tx);
ConfirmedStore.TryAdd(found);
}
else
@@ -130,7 +130,7 @@ namespace WalletWasabi.Transactions
{
if (ConfirmedStore.TryGetTransaction(hash, out SmartTransaction found))
{
- found.Update(tx);
+ found.TryUpdate(tx);
}
else
{
@@ -155,12 +155,12 @@ namespace WalletWasabi.Transactions
// Do Contains first, because it's fast.
if (ConfirmedStore.Contains(hash) && ConfirmedStore.TryGetTransaction(hash, out originalTx))
{
- originalTx.Update(tx);
+ originalTx.TryUpdate(tx);
return true;
}
else if (MempoolStore.Contains(hash) && MempoolStore.TryGetTransaction(hash, out originalTx))
{
- originalTx.Update(tx);
+ originalTx.TryUpdate(tx);
// If confirmed update the height.
if (originalTx.Confirmed && MempoolStore.TryRemove(hash, out originalTx))
@@ -188,7 +188,7 @@ namespace WalletWasabi.Transactions
&& MempoolStore.TryRemove(hash, out SmartTransaction uTx)
&& ConfirmedStore.TryGetTransaction(hash, out SmartTransaction cTx))
{
- cTx.Update(uTx);
+ cTx.TryUpdate(uTx);
}
}
}

MODIFY
WalletWasabi/Transactions/TransactionStore.cs
WalletWasabi/Transactions/TransactionStore.cs
@@ -119,7 +119,7 @@ namespace WalletWasabi.Transactions
}
else
{
- Transactions[hash].Update(tx);
+ Transactions[hash].TryUpdate(tx);
return false;
}
}

Make stx update tryupdate