Post
Topic
Board Mining (Altcoins)
Re: C# mining app project
by
Sokander
on 31/01/2022, 13:48:30 UTC
I want to do it in C# because it's my main language I do everything with and I do love WPF  Cool

It's your choice but you'll have to learn c anyway to port the algos to c#. And don't use scrypt, it's
no longer viable for CPU mining. Choose a CPU mineable algo.

Is there a simple algorithm to understand ?

I do not understand what this code is trying to do, what does meet the target means.

Code:
// Reference: https://github.com/replicon/Replicon.Cryptography.SCrypt
public void doScrypt(byte[] Tempdata, byte[] Target, uint Nonce, uint Increment)
{
    double Hashcount = 0;

    byte[] Databyte = new byte[80];
    Array.Copy(Tempdata, 0, Databyte, 0, 76);

    Debug.WriteLine("New thread");
           
    DateTime StartTime = DateTime.Now;

    // Loop until done is set or we meet the target
    while (!done)
    {
        Databyte[76] = (byte)(Nonce >> 0);
        Databyte[77] = (byte)(Nonce >> 8);
        Databyte[78] = (byte)(Nonce >> 16);
        Databyte[79] = (byte)(Nonce >> 24);

        var ScryptResult = Replicon.Cryptography.SCrypt.SCrypt.DeriveKey(Databyte, Databyte, 1024, 1, 1, 32);

        Hashcount++;

        if (meetsTarget(ScryptResult, Target))  // Did we meet the target?
        {
            if (!done)
            {
                FinalNonce = Nonce;
            }

            done = true;

            break;
        }
        else
        {
            Nonce += Increment; // If not, increment the nonce and try again
        }
    }

    double Elapsedtime = (DateTime.Now - StartTime).TotalMilliseconds;
    Console.WriteLine("Thread finished - {0:0} hashes in {1:0.00} ms. Speed: {2:0.00} kHash/s", Hashcount, Elapsedtime, Hashcount / Elapsedtime);
}