void OnWorkRejected(IPool arg1, IPoolWork arg2, IMiningDevice arg3, IShareResponse arg4) { if (this.WorkRejected != null) { this.WorkRejected(arg1, arg2, arg3, arg4); } }
private void StartWorkOnDevice(IPoolWork work, bool defaultNonce, long startingNonce = 0, long endingNonce = 0xFFFFFFFF) { if (this.usbPort != null && this.usbPort.IsOpen) { this.RestartWatchdogTimer(); if (LogHelper.ShouldDisplay(LogVerbosity.Verbose)) { LogHelper.ConsoleLog(string.Format("Device {0} starting work {1}.", this.Name, work.JobId), LogVerbosity.Verbose); } this.RestartWorkRequestTimer(); if (defaultNonce) { this.SendWorkToDevice(work); } else { this.SendWorkToDevice(work, startingNonce, endingNonce); } } else { LogHelper.DebugConsoleLog(string.Format("Device {0} pending work {1}.", this.Name, work.JobId), LogVerbosity.Verbose); this.pendingWork = work; this.pendingWorkStartNonce = startingNonce; this.pendingWorkEndNonce = endingNonce; } }
void OnWorkAccepted(IPool arg1, IPoolWork arg2, IMiningDevice arg3) { if (this.WorkAccepted != null) { this.WorkAccepted(arg1, arg2, arg3); } }
void OnNewWorkRecieved(IPool arg1, IPoolWork arg2, bool arg3) { if (this.NewWorkRecieved != null) { this.NewWorkRecieved(arg1, arg2, arg3); } }
protected void StartNewWork(IPoolWork work) { currentWork = work; nextWork = work; working = true; StartWork(work, null, true, false); }
public virtual void InvalidNonce(IMiningDevice device, IPoolWork work) { if (this.ActivePool != null) { this.ActivePool.HardwareErrors++; this.ActivePool.DiscardedWorkUnits += work.Diff; } }
private void WorkUpdateTimerExipred(object sender, System.Timers.ElapsedEventArgs e) { if (currentWork != nextWork) { currentWork = nextWork; } this.OnWorkUpdateTimerExpired(); }
public override void StartWork(IPoolWork work) { LogHelper.ConsoleLog(new object[] { string.Format("Miner {0} starting work {1} with:", Path, work.JobId), string.Format("\tDiff: {0}", work.Diff), string.Format("\tHeader: {0}", work.Header) }, LogVerbosity.Verbose); }
public void SubmitWork(IPoolWork work, IMiningDevice device, string nonce) { StratumWork stratumWork = work as StratumWork; if (stratumWork != null && device != null && nonce != null && this.submissionQueue != null) { this.submissionQueue.Add(new Tuple <StratumWork, IMiningDevice, string>(stratumWork, device, nonce)); } }
protected override void NoWork(IPoolWork oldWork, IMiningDevice device, bool requested) { StratumWork stratumWork = oldWork as StratumWork; if (stratumWork != null) { LogHelper.DebugConsoleLog("No new work, making new work."); StartWorkOnDevice(stratumWork, device, false, requested); } }
protected void OnInvalidNonce(IPoolWork work) { if (this.InvalidNonce != null) { Task.Factory.StartNew(() => { this.InvalidNonce(this, work); }); } }
public override void StartWork(IPoolWork work, long startingNonce, long endingNonce) { LogHelper.ConsoleLog(new object[] { string.Format("Miner {0} starting work {1} with:", Path, work.JobId), string.Format("\tDiff: {0}", work.Diff), string.Format("\tHeader: {0}", work.Header), string.Format("\tStartNonce: {0:X8}", startingNonce), string.Format("\tEndNonce: {0:X8}", endingNonce) }, LogVerbosity.Verbose); }
void Miner_WorkAccepted(IPool arg1, IPoolWork arg2, IMiningDevice arg3) { this.UpdateHashrate(arg1); MiningDeviceData data; if (DeviceMap.TryGetValue(arg3, out data)) { data.UpdatedHashRate(arg3); } }
void Miner_WorkRejected(IPool arg1, IPoolWork arg2, IMiningDevice arg3, IShareResponse arg4) { this.UpdateHashrate(arg1); MiningDeviceData data; if (DeviceMap.TryGetValue(arg3, out data)) { data.UpdatedHashRate(arg3); } }
protected void OnValidNonce(IPoolWork work, string nonce) { this.RestartWatchdogTimer(); if (this.ValidNonce != null) { Task.Factory.StartNew(() => { this.ValidNonce(this, work, nonce); }); } }
protected virtual void OnWorkAccepted(IPool pool, IPoolWork work, IMiningDevice device) { device.Accepted++; device.AcceptedWorkUnits += work.Diff; DisplayDeviceStats(device); if (this.WorkAccepted != null) { this.WorkAccepted(pool, work, device); } }
protected override void StartWork(IPoolWork work, IMiningDevice device, bool restartAll, bool requested) { StratumWork stratumWork = work as StratumWork; if (stratumWork != null) { LogHelper.DebugConsoleLog("Starting new work on devices."); currentExtraNonce2 = Random.Next(); StartWorkOnDevice(stratumWork, device, (restartAll || (AlwaysForceRestart && (mostRecentWork == null || mostRecentWork.JobId != work.JobId))), requested); mostRecentWork = stratumWork; } }
protected override void OnWorkRejected(IPool pool, IPoolWork work, IMiningDevice device, IShareResponse response) { base.OnWorkRejected(pool, work, device, response); if (response.JobNotFound || response.RejectReason.Contains("job not found") || response.RejectReason.Contains("stale")) { if (LogHelper.ShouldDisplay(LogVerbosity.Verbose)) { LogHelper.ConsoleLog(string.Format("Device {0} submitted stale share. Restarting with new work.", device.Name), LogVerbosity.Verbose); } this.RequestWork(device); } }
public virtual void SubmitWork(IMiningDevice device, IPoolWork work, string nonce) { if (started && this.ActivePool != null && currentWork != null && this.ActivePool.IsConnected) { this.ActivePool.SubmitWork(work, device, nonce); StartWorkOnDevice(work, device, false); } else if (this.ActivePool != null && !this.ActivePool.IsConnected && !this.ActivePool.IsConnecting) { //Attempt to connect to another pool this.AttemptPoolReconnect(); } }
private void DivideUpNonces(IPoolWork work, long startingNonce, long endingNonce) { double noncesPerChip = (endingNonce - startingNonce) / _totalChips; long start = 0; foreach (GridseedDevice d in LoadedDevices) { long end = (long)(start + d.Chips * noncesPerChip); d.StartWork(work, start, end); start = end + 1; } }
private void SetDefaultValues() { Chips = defaultChips; Frequency = defaultFreq; _currentWork = null; _currentTaskId = 0; _ResponsePacket = new byte[24]; _CommandBuf = new byte[156]; // Encode the command header (4 bytes) _CommandBuf[0] = 0x55; _CommandBuf[1] = 0xaa; _CommandBuf[2] = 0x1f; _CommandBuf[3] = 0x00; }
protected virtual void OnWorkRejected(IPool pool, IPoolWork work, IMiningDevice device, IShareResponse response) { if (!response.IsLowDifficlutyShare && !response.RejectReason.Contains("low difficulty") && !response.RejectReason.Contains("above target")) { device.Rejected++; device.RejectedWorkUnits += work.Diff; if (this.WorkRejected != null) { this.WorkRejected(pool, work, device, response); } } else { // Fix for bug where some pools will change the difficluty in the middle of a job and expect shares at the new difficluty if (pool.Diff > work.Diff) { LogHelper.DebugLogError(string.Format("Submitted share with low difficluty while pool diff was different than work diff. P: {0} W: {0}", pool.Diff, work.Diff)); LogHelper.DebugConsoleLog("Restarting work on all to attempt to synchronize difficluty.", ConsoleColor.Red, LogVerbosity.Quiet); IPoolWork newWork = work.Clone() as IPoolWork; newWork.Diff = pool.Diff; StartNewWork(newWork); } device.HardwareErrors++; device.DiscardedWorkUnits += work.Diff; if (this.ActivePool != null) { this.ActivePool.Rejected--; this.ActivePool.RejectedWorkUnits -= work.Diff; this.ActivePool.HardwareErrors++; this.ActivePool.DiscardedWorkUnits += work.Diff; } } DisplayDeviceStats(device); if (this.WorkDiscarded != null) { this.WorkDiscarded(pool, work, device); } }
public void NewWork(IPool pool, IPoolWork newWork, bool forceStart) { if (this.NewWorkRecieved != null) { Task.Factory.StartNew(() => { this.NewWorkRecieved(pool, newWork, forceStart); }); } longWait = false; reconnectionAttempts = 0; // We know that we've connected to something now poolReconnectingTo = null; if (started && ActivePool != null) { if (newWork != null) { RestartWorkUpdateTimer(); OnNewWork(pool, newWork, forceStart); // Pool asked us to toss out our old work or we don't have any work yet if (forceStart || currentWork == null) { StartNewWork(newWork); } else // We can keep the old work { if (!working) { currentWork = newWork; nextWork = newWork; working = true; StartWork(newWork, null, false, false); } else { nextWork = newWork; } } } } }
public void StartWorkOnDevice(IPoolWork work, IMiningDevice device, bool requested) { if (nextWork != null && currentWork != null) { if (nextWork.JobId != currentWork.JobId || nextWork.Diff != currentWork.Diff) { // Start working on the last thing the server sent us currentWork = nextWork; StartWork(nextWork, device, false, requested); } else { working = false; NoWork(work, device, requested); } } }
private void SendWork(IPoolWork work, long startingNonce = 0) { try { if (work != null) { timesNonZero = 0; int diffCode = 0xFFFF / work.Diff; byte[] cmd = _commandPacket; cmd[3] = (byte)diffCode; cmd[2] = (byte)(diffCode >> 8); int offset = 4; // Starting nonce cmd[offset] = (byte)startingNonce; cmd[offset + 1] = (byte)(startingNonce >> 8); cmd[offset + 2] = (byte)(startingNonce >> 16); cmd[offset + 3] = (byte)(startingNonce >> 24); offset += 4; byte[] headerBytes = work.Header.Reverse().ToArray(); headerBytes.CopyTo(cmd, offset); LogHelper.DebugConsoleLog(string.Format("{0} getting: {1}", this.Name, HexConversionHelper.ConvertToHexString(cmd))); LogHelper.DebugLogToFile(string.Format("{0} getting: {1}", this.Name, HexConversionHelper.ConvertToHexString(cmd)), deviceLogFile); // Send work to the miner this.currentWork = work; this.usbPort.DiscardInBuffer(); this.SendCommand(cmd); } } catch (Exception e) { LogHelper.LogError(e); throw e; } }
public override void WorkRejected(IPoolWork work) { throw new NotImplementedException(); }
protected abstract void SendWorkToDevice(IPoolWork work, long startingNonce, long endingNonce);
protected abstract void SendWorkToDevice(IPoolWork work);
public override void StartWork(IPoolWork work, long startingNonce, long endingNonce) { this.StartWorkOnDevice(work, false, startingNonce, endingNonce); }
public override void StartWork(IPoolWork work) { this.StartWorkOnDevice(work, true); }