Пример #1
0
        public void Submit(Device aDevice, StandardStratum.Work work, UInt32 aNonce)
        {
            if (Stopped)
            {
                return;
            }

            lock (thisLock)
            {
                ReportSubmittedShare(aDevice);
                try
                {
                    String stringNonce = (String.Format("{3:x2}{2:x2}{1:x2}{0:x2}", ((aNonce >> 0) & 0xff), ((aNonce >> 8) & 0xff), ((aNonce >> 16) & 0xff), ((aNonce >> 24) & 0xff)));
                    String message     = JsonConvert.SerializeObject(new Dictionary <string, Object> {
                        { "id", mJsonRPCMessageID },
                        { "method", "mining.submit" },
                        { "params", new List <string> {
                              Username,
                              work.Job.ID,
                              work.LocalExtranonceString,
                              work.Job.NTime,
                              stringNonce
                          } }
                    });
                    WriteLine(message);
                    ++mJsonRPCMessageID;
                }
                catch (Exception ex)
                {
                    Program.Logger("Failed to submit share: " + ex.Message + "\nReconnecting to the server...");
                    Reconnect();
                }
            }
        }
Пример #2
0
        public void workLoop()
        {
            // Wait for the first PascalJob to arrive.
            int elapsedTime = 0;

            while ((kcs.GetJob() == null) && !stopped)
            {
                System.Threading.Thread.Sleep(100);
                elapsedTime += 100;
                if (elapsedTime >= 5000)
                {
                    Program.Logger("Waiting for job from pool...\n");
                    elapsedTime = 0;
                }
            }



            while (!stopped)
            {
                // Each time pascalWork.Blob gives a different blob for the same work, so this is how we get more 32bit nonce search areas...
                // Just have to rerun this loop at a higher rate then we run out of work nonces...
                // For now let's make sure we call this at least every 2s, that means we can support hash speeds up to 2GH/s .
                // Callback will be asyncrhonus, so have to lock cur and pre work while updating them.
                lock (this)
                {
                    prevWork = curWork;                             // remember the old work item in case the miner reports finished work on it, we can still hand them in (if the job is the same).
                    curWork  = kcs.GetWork();                       // Get a new work item (can be for the same job).
                    keccakWorker.NewWork(curWork.Blob);
                }

                // let's do 200 loops, 10ms delay each loop, should be less then 4s.  Then bail out if we get new orders from pool ofcourse.
                //for (int i = 0; i < 200; i++)
                for (int i = 0; i < 200; i++)
                {
                    if (stopped || (kcs.GetJob().Equals(curWork.Job) == false))
                    {
                        Console.WriteLine("DEBUG - BREAK TO GIVE NEW POOL JOB");
                        break;
                    }
                    System.Threading.Thread.Sleep(10);
                }
            }
        }