public void Submit(Device aDevice, PascalStratum.Work work, UInt32 aNonce) { if (Stopped) { return; } try { mMutex.WaitOne(5000); } catch (Exception) { } 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(); } try { mMutex.ReleaseMutex(); } catch (Exception) { } }
public void workLoop() { // Wait for the first PascalJob to arrive. int elapsedTime = 0; while ((ps.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 . PascalStratum.Work stratumWork = ps.GetWork(); // Get a new work item (can be for the same job). // 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 = new PascalMinerWork(stratumWork); curWork.sendWorkToWorker(pascalWorker); } // 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++) { if (stopped || (ps.GetJob().Equals(stratumWork.Job) == false)) { break; } System.Threading.Thread.Sleep(10); } } }
public PascalMinerWork(PascalStratum.Work work) { this.work = work; CalculatePascalMidState(); }