Hash:GetHashCode()
authorCryptoManiac <balthazar.ad@gmail.com>
Fri, 28 Aug 2015 14:06:33 +0000 (17:06 +0300)
committerCryptoManiac <balthazar.ad@gmail.com>
Fri, 28 Aug 2015 14:06:33 +0000 (17:06 +0300)
Now it's necessary because we want to use hash as key for dictionary.

Novacoin/Hash.cs

index 822cadd..bbb01bf 100644 (file)
@@ -94,8 +94,15 @@ namespace Novacoin
 
         public override int GetHashCode()
         {
-            // It's a hash already, so any idea of trying to get its hashcode doesn't make any sense to me
-            throw new NotSupportedException();
+            int hash = 17;
+            unchecked
+            {
+                foreach (var element in _hashBytes)
+                {
+                    hash = hash * 31 + element.GetHashCode();
+                }
+            }
+            return hash;
         }
 
         public int CompareTo(Hash item)