/// <summary> /// Update the transaction with the data acquired from another transaction. (For example merge their labels.) /// </summary> public void Update(SmartTransaction tx) { // If this is not the same tx, then don't update. if (this != tx) { throw new InvalidOperationException($"{GetHash()} != {tx.GetHash()}"); } // Set the height related properties, only if confirmed. if (tx.Confirmed) { Height = tx.Height; BlockHash = tx.BlockHash; BlockIndex = tx.BlockIndex; } // Always the earlier seen is the firstSeen. if (tx.FirstSeen < FirstSeen) { FirstSeen = tx.FirstSeen; } // Merge labels. if (Label != tx.Label) { Label = SmartLabel.Merge(Label, tx.Label); } }
/// <summary> /// Update the transaction with the data acquired from another transaction. (For example merge their labels.) /// </summary> public bool TryUpdate(SmartTransaction tx) { var updated = false; // If this is not the same tx, then don't update. if (this != tx) { throw new InvalidOperationException($"{GetHash()} != {tx.GetHash()}"); } // Set the height related properties, only if confirmed. if (tx.Confirmed) { if (Height != tx.Height) { Height = tx.Height; updated = true; } if (tx.BlockHash != null && BlockHash != tx.BlockHash) { BlockHash = tx.BlockHash; 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); }