HashCompare() public static method

public static HashCompare ( byte hashA, byte hashB ) : bool
hashA byte
hashB byte
return bool
Ejemplo n.º 1
0
        Block FindBlock(byte[] hash)
        {
            Block found = null;

            mBlockLock.WaitOne();
            foreach (Block b in mBlocks)
            {
                if (Utils.HashCompare(b.mHeader.mHash, hash))
                {
                    found = b;
                    break;
                }
            }
            mBlockLock.ReleaseMutex();

            return(found);
        }
Ejemplo n.º 2
0
        public bool ValidateHash()
        {
            byte[] oldHash = mHash;
            ComputeHash(false);
            byte[] sha256 = mHash;
            ComputeHash(true);
            byte[] scrypt = mHash;
            mHash = oldHash;

            if (Utils.HashCompare(oldHash, sha256))
            {
                return(false);
            }
            if (!Utils.HashCompare(oldHash, scrypt))
            {
                Console.WriteLine("Neither sha256 or scrypt generated a matching hash");
            }

            return(true);
        }
Ejemplo n.º 3
0
 void MergePendingHeaders()
 {
     mBlockLock.WaitOne();
     if (mBlocks.Count > 0)
     {
         for (int i = mBlocks.Count - 1; i >= 0; i--)
         {
             if (Utils.HashCompare(mBlocks[i].mHeader.mHash, mPendingHeaders[0].mPrevBlock))
             {
                 if (i < (mBlocks.Count - 1))
                 {
                     Console.WriteLine("Stop here and figure out how to handle this case!!!");
                 }
                 else
                 {
                     foreach (BlockHeader h in mPendingHeaders)
                     {
                         Block b = new Block();
                         b.mHeader = h;
                         mBlocks.Add(b);
                         b.mHeight = mCurrentHeight++;
                     }
                 }
             }
         }
     }
     else
     {
         // No blocks yet, just dump all these into the block list
         foreach (BlockHeader h in mPendingHeaders)
         {
             Block b = new Block();
             b.mHeader = h;
             mBlocks.Add(b);
             b.mHeight = mCurrentHeight++;
         }
     }
     mBlockLock.ReleaseMutex();
 }