Example #1
0
        public CPU(NetworkInterface.INetworkInterface networkInterface, Device.CPU devices, bool isSubmitStale, int pauseOnFailedScans)
            : base(networkInterface, new Device.DeviceBase[] { devices }, isSubmitStale, pauseOnFailedScans)
        {
            try
            {
                HasMonitoringAPI = false;

                UnmanagedInstance = Helper.CPU.Solver.GetInstance();

                AssignDevices();
            }
            catch (Exception ex)
            {
                PrintMessage("CPU", string.Empty, -1, "Error", ex.Message);
            }
        }
Example #2
0
 public Config() // set defaults
 {
     isLogFile              = false;
     minerJsonAPI           = Defaults.JsonAPIPath;
     minerCcminerAPI        = Defaults.CcminerAPIPath;
     web3api                = Defaults.InfuraAPI_mainnet;
     contractAddress        = Defaults.Contract0xBTC_mainnet;
     abiFile                = Defaults.AbiFile0xBTC;
     overrideMaxTarget      = new HexBigInteger(BigInteger.Zero);
     customDifficulty       = BigInteger.Zero;
     submitStale            = Defaults.SubmitStale;
     maxScanRetry           = Defaults.MaxScanRetry;
     pauseOnFailedScans     = Defaults.PauseOnFailedScan;
     networkUpdateInterval  = Defaults.NetworkUpdateInterval;
     hashrateUpdateInterval = Defaults.HashrateUpdateInterval;
     masterMode             = false;
     masterURL              = string.Empty;
     kingAddress            = string.Empty;
     minerAddress           = DevFee.Address;
     slaveUpdateInterval    = Defaults.SlaveUpdateInterval;
     primaryPool            = Defaults.PoolPrimary;
     secondaryPool          = string.Empty;
     privateKey             = string.Empty;
     gasToMine              = Defaults.GasToMine;
     gasLimit               = Defaults.GasLimit;
     gasApiURL              = Defaults.GasApiURL;
     gasApiPath             = Defaults.GasApiPath;
     gasApiMultiplier       = Defaults.GasApiMultiplier;
     gasApiOffset           = Defaults.GasApiOffset;
     gasApiMax              = Defaults.GasApiMax;
     allowCPU               = false;
     cpuDevice              = new Miner.Device.CPU();
     allowIntel             = true;
     intelDevices           = new Miner.Device.OpenCL[] { };
     allowAMD               = true;
     amdDevices             = new Miner.Device.OpenCL[] { };
     allowCUDA              = true;
     cudaDevices            = new Miner.Device.CUDA[] { };
 }
Example #3
0
        private void StartThreadFinding(Device.CPU device, Structs.Processor processor, bool isKingMaking)
        {
            try
            {
                var errorMessage     = new StringBuilder(1024);
                var currentChallenge = (byte[])Array.CreateInstance(typeof(byte), UINT256_LENGTH);

                DateTime loopStartTime;
                int      loopTimeElapsed;
                double   timeAccuracy;
                var      loopTimeTarget = (int)(m_hashPrintTimer.Interval * 0.1);

                var processorIndex = -1;
                for (var i = 0; i < device.Processor_Structs.Length; i++)
                {
                    if (device.Processor_Structs[i].Affinity == processor.Affinity)
                    {
                        processorIndex = i;
                    }
                }

                Helper.CPU.Solver.SetThreadAffinity(UnmanagedInstance, processor.Affinity, errorMessage);
                if (errorMessage.Length > 0)
                {
                    PrintMessage(device.Type, device.Platform, processorIndex, "Error", errorMessage.ToString());
                    return;
                }

                device.HashStartTime = DateTime.Now;
                device.HashCount     = 0;
                device.IsMining      = true;
                do
                {
                    while (device.IsPause)
                    {
                        Task.Delay(500).Wait();
                        device.HashStartTime = DateTime.Now;
                        device.HashCount     = 0;
                    }

                    CheckInputs(device, isKingMaking, ref currentChallenge);

                    Work.IncrementPosition(ref processor.WorkPosition, processor.WorkSize);

                    lock (device)
                        device.HashCount += processor.WorkSize;

                    loopStartTime = DateTime.Now;

                    if (isKingMaking)
                    {
                        Helper.CPU.Solver.HashMessage(UnmanagedInstance, ref device.DeviceCPU_Struct, ref processor);
                    }
                    else
                    {
                        Helper.CPU.Solver.HashMidState(UnmanagedInstance, ref device.DeviceCPU_Struct, ref processor);
                    }

                    loopTimeElapsed = (int)(DateTime.Now - loopStartTime).TotalMilliseconds;

                    timeAccuracy = (float)loopTimeTarget / loopTimeElapsed;

                    if (timeAccuracy > 1.2f || timeAccuracy < 0.8f)
                    {
                        processor.WorkSize = (ulong)(timeAccuracy * processor.WorkSize);
                    }

                    if (processor.SolutionCount > 0)
                    {
                        SubmitSolutions(device.Solutions[processorIndex].ToArray(),
                                        currentChallenge,
                                        device.Type,
                                        device.Platform,
                                        device.DeviceID,
                                        processor.SolutionCount,
                                        isKingMaking);

                        processor.SolutionCount = 0;
                    }
                } while (device.IsMining);

                if (processor.Affinity == device.Processor_Structs.First().Affinity)
                {
                    PrintMessage(device.Type, device.Platform, device.DeviceID, "Info", "Stop mining...");
                }

                device.HashCount     = 0;
                device.IsStopped     = true;
                device.IsInitialized = false;
            }
            catch (Exception ex)
            {
                PrintMessage(device.Type, device.Platform, -1, "Error", ex.Message);
            }
            if (processor.Affinity == device.Processor_Structs.First().Affinity)
            {
                PrintMessage(device.Type, device.Platform, device.DeviceID, "Info", "Mining stopped.");
            }
        }