Пример #1
0
        public void Work()
        {
            //while (_pool != null && !_shouldStop)
            //{
            var work = new Work[_workThreads];

            if (work[0] == null || work[0].Age > MaxAgeTicks)
            {
                work[0] = _pool.GetWork();
            }

            work[0].WorkerID = 0;
            /* Clone work */
            for (var y = 1; y < _workThreads; ++y)
            {
                work[y] = new Work(work[0])
                {
                    WorkerID = y
                }
            }
            ;

            /* fire off work in separate threads */
            for (var x = 0; x < _workThreads; x++)
            {
                var nonce = (uint)x;
                while (!_shouldStop && work != null && (isTesting && nonce <= 7100000))
                {
                    if (work[x].LookForShare(ref nonce, BatchSize, _workThreads))
                    {
                        work[x].FinalNonce = nonce;
                        work[x].CalculateShare(nonce);
                        SendWorkQueue.SendShare(work[x]);
                        work = null;
                    }
                    else
                    {
                        work[x].FinalNonce = nonce;
                        var s = work[x].GetCurrentStateString(nonce);
                        ThreadPool.QueueUserWorkItem(delegate
                        {
                            Program.ClearConsole();
                            Program.Print(s);
                        });
                    }

                    if (isTesting)
                    {
                        work[x].FinalNonce = nonce;
                        work[x].CalculateShare(nonce);
                        SendWorkQueue.SendShare(work[x]);
                    }
                }
            }
            ;
            //}
        }
Пример #2
0
 private static Work GetWork()
 {
     ClearConsole();
     Print("Requesting Work from Pool...");
     Print("Server URL: " + _pool.Url.ToString());
     Print("User: "******"Password: " + _pool.Password);
     return(_pool.GetWork());
 }