private void NetworkInterface_OnGetMiningParameterStatus(NetworkInterface.INetworkInterface sender, bool success) { try { if (UnmanagedInstance != null && UnmanagedInstance.ToInt64() != 0) { if (success) { var isPause = Devices.All(d => d.IsPause); if (m_isCurrentChallengeStopSolving) { isPause = true; } else if (isPause) { if (m_failedScanCount > m_pauseOnFailedScan) { m_failedScanCount = 0; } isPause = false; } foreach (var device in Devices) { device.IsPause = isPause; } } else { m_failedScanCount++; var isMining = Devices.Any(d => d.IsMining); if (m_failedScanCount > m_pauseOnFailedScan && IsMining) { foreach (var device in Devices) { device.IsPause = true; } } } } } catch (Exception ex) { PrintMessage(string.Empty, string.Empty, -1, "Error", ex.Message); } }
private void NetworkInterface_OnNewChallenge(NetworkInterface.INetworkInterface sender, byte[] challenge, string address) { try { if (UnmanagedInstance != null && UnmanagedInstance.ToInt64() != 0) { for (var i = 0; i < challenge.Length; i++) { m_ChallengeBytes[i] = challenge[i]; } m_AddressString = address; // some pools provide invalid checksum address Utils.Numerics.AddressStringToByte20Array(address, ref m_AddressBytes, isChecksum: false); m_SolutionTemplateBytes = Work.SolutionTemplate; m_MidStateBytes = Helper.CPU.GetMidState(m_ChallengeBytes, m_AddressBytes, m_SolutionTemplateBytes); foreach (var device in Devices) { Array.ConstrainedCopy(m_ChallengeBytes, 0, device.Message, 0, UINT256_LENGTH); Array.ConstrainedCopy(m_AddressBytes, 0, device.Message, UINT256_LENGTH, ADDRESS_LENGTH); Array.ConstrainedCopy(m_SolutionTemplateBytes, 0, device.Message, UINT256_LENGTH + ADDRESS_LENGTH, UINT256_LENGTH); Array.Copy(m_ChallengeBytes, device.Challenge, UINT256_LENGTH); Array.Copy(m_MidStateBytes, device.MidState, SPONGE_LENGTH); device.HasNewChallenge = true; } if (m_isCurrentChallengeStopSolving) { foreach (var device in Devices) { device.IsPause = false; } m_isCurrentChallengeStopSolving = false; } } } catch (Exception ex) { PrintMessage(string.Empty, string.Empty, -1, "Error", ex.Message); } }