public void ComputeHash(bool useScrypt) { MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); bw.Write(mVersion); bw.Write(mPrevBlock); bw.Write(mMerkleRoot); bw.Write(mTimestamp); bw.Write(mDifficultyBits); bw.Write(mNOnce); byte[] data = ms.ToArray(); bw.Close(); if (useScrypt) { Work work = new Work(); Buffer.BlockCopy(data, 0, work.data, 0, 80); for (int i = 0; i < 20; i++) work.data[i] = Program.Byteswap(work.data[i]); Scrypt scrypt = new Scrypt(work); mHash = scrypt.GetHash(); } else { // SHA 256 mHash = Scrypt.SHA2562(data); } }
public static bool TestStandard() { Work work = new Work(); Array.Copy(sData, work.data, 32); Array.Copy(sTarget, work.target, 8); Scrypt scrypt = new Scrypt(work); bool result = scrypt.Hash(sNOnce); return result; }
public static bool TestStandard() { Work work = new Work(); Array.Copy(sData, work.data, 32); Array.Copy(sTarget, work.target, 8); Scrypt scrypt = new Scrypt(work); bool result = scrypt.Hash(sNOnce); return(result); }
void ScryptHashes() { ulong end = mHashStart + mHashCount; Scrypt scryptData = new Scrypt(mWork); for( ulong i = mHashStart; i < end; i++ ) { mHashesDone++; bool success = scryptData.Hash((uint)i); if( success ) { mSolution = (uint)i; mSolutionFound = true; break; } } }
void ScryptHashes() { ulong end = mHashStart + mHashCount; Scrypt scryptData = new Scrypt(mWork); for (ulong i = mHashStart; i < end; i++) { mHashesDone++; bool success = scryptData.Hash((uint)i); if (success) { mSolution = (uint)i; mSolutionFound = true; break; } } }
public void Update(Connection conn) { if (mCurrentWork != null) { bool threadsAllDone = true; foreach (WorkThread t in mThreads) { if (!t.IsWorkDone()) { threadsAllDone = false; break; } } if (threadsAllDone) { uint hashes = 0; uint solution = 0; bool solutionFound = false; foreach (WorkThread t in mThreads) { hashes += t.HashesDone; if (t.SolutionFound) { solutionFound = true; solution = t.Solution; } } conn.SendWorkComplete(solutionFound, Scrypt.ByteReverse(solution), hashes); mCurrentWork = null; mTimer.Stop(); mHashRate = (uint)((double)hashes / mTimer.GetDuration()); } } }