Calculation of ValueIn and nSigops, implementation of IEqualityComparer<COutPoint>
[NovacoinLibrary.git] / Novacoin / COutPoint.cs
index b236ccd..07c6552 100644 (file)
@@ -25,7 +25,7 @@ using System.Text;
 
 namespace Novacoin
 {
-    public class COutPoint : IComparable<COutPoint>, IEquatable<COutPoint>
+    public class COutPoint : IComparable<COutPoint>, IEquatable<COutPoint>, IEqualityComparer<COutPoint>
     {
         /// <summary>
         /// Hash of parent transaction.
@@ -135,6 +135,27 @@ namespace Novacoin
 
             return (o.n == n) && (o.hash == hash);
         }
+
+        /// <summary>
+        /// Equality comparer for outpoints.
+        /// </summary>
+        /// <param name="x">First outpoint.</param>
+        /// <param name="y">Second outpoint.</param>
+        /// <returns>Result of comparison.</returns>
+        public bool Equals(COutPoint x, COutPoint y)
+        {
+            return (x.n == y.n) && (x.hash == y.hash);
+        }
+
+        public override int GetHashCode()
+        {
+            return n.GetHashCode() ^ hash.GetHashCode();
+        }
+
+        public int GetHashCode(COutPoint obj)
+        {
+            return obj.GetHashCode();
+        }
     }
 
 }