コード例 #1
0
        public static Tuple <ComputeDevice, DeviceMiningStatus> getDeviceMiningStatus(ComputeDevice device)
        {
            DeviceMiningStatus status = DeviceMiningStatus.CanMine;

            if (device == null)   // C# is null happy
            {
                status = DeviceMiningStatus.DeviceNull;
            }
            else if (device.Enabled == false)
            {
                status = DeviceMiningStatus.Disabled;
            }
            else
            {
                bool hasEnabledAlgo = false;
                foreach (Algorithm algo in device.GetAlgorithmSettings())
                {
                    hasEnabledAlgo |= IsAlgoMiningCapable(algo) && MinerPaths.IsValidMinerPath(algo.MinerBinaryPath);
                }
                if (hasEnabledAlgo == false)
                {
                    status = DeviceMiningStatus.NoEnabledAlgorithms;
                }
            }
            return(new Tuple <ComputeDevice, DeviceMiningStatus>(device, status));
        }
コード例 #2
0
 private static void LogMiningNonMiningStatuses(List <MiningDevice> enabledDevices, List <Tuple <ComputeDevice, DeviceMiningStatus> > disabledDevicesStatuses)
 {
     // print statuses
     if (disabledDevicesStatuses.Count > 0)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("");
         stringBuilder.AppendLine("Disabled Devices:");
         foreach (var deviceStatus in disabledDevicesStatuses)
         {
             stringBuilder.AppendLine("\t" + GetDisabledDeviceStatusString(deviceStatus));
         }
         Helpers.ConsolePrint(TAG, stringBuilder.ToString());
     }
     if (enabledDevices.Count > 0)
     {
         // print enabled
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("");
         stringBuilder.AppendLine("Enabled Devices for Mining session:");
         foreach (var miningDevice in enabledDevices)
         {
             var device = miningDevice.Device;
             stringBuilder.AppendLine(String.Format("\tENABLED ({0})", device.GetFullName()));
             foreach (var algo in device.GetAlgorithmSettings())
             {
                 var isEnabled = IsAlgoMiningCapable(algo) && MinerPaths.IsValidMinerPath(algo.MinerBinaryPath);
                 stringBuilder.AppendLine(String.Format("\t\tALGORITHM {0} ({1})",
                                                        isEnabled ? "ENABLED " : "DISABLED", // ENABLED/DISABLED
                                                        algo.AlgorithmStringID));
             }
         }
         Helpers.ConsolePrint(TAG, stringBuilder.ToString());
     }
 }
コード例 #3
0
 public MiningAlgorithm(ComputeDevice dev, Algorithm algo)
 {
     this.AlgoRef = algo;
     // init speed that will be avaraged later
     this.AvaragedSpeed = algo.BenchmarkSpeed;
     this.MinerPath     = MinerPaths.GetOptimizedMinerPath(dev, algo);
 }
コード例 #4
0
ファイル: GroupMiner.cs プロジェクト: jerlis/NiceHashMiner
        //private string _miningLocation = "";
        //private string _btcAdress = "";
        //private string _worker = "";

        // , string miningLocation, string btcAdress, string worker
        public GroupMiner(List <MiningPair> miningPairs, string key)
        {
            AlgorithmType     = AlgorithmType.NONE;
            DevicesInfoString = "N/A";
            CurrentRate       = 0;
            Key = key;
            if (miningPairs.Count > 0)
            {
                // sort pairs by device id
                miningPairs.Sort((a, b) => a.Device.ID - b.Device.ID);
                // init name scope
                {
                    List <string> deviceNames = new List <string>();
                    foreach (var pair in miningPairs)
                    {
                        deviceNames.Add(pair.Device.NameCount);
                    }
                    DevicesInfoString = "{ " + string.Join(", ", deviceNames) + " }";
                }
                // init miner
                {
                    var mPair = miningPairs[0];
                    DeviceType = mPair.Device.DeviceType;
                    Miner      = MinersManager.CreateMiner(mPair.Device.DeviceType,
                                                           MinerPaths.GetOptimizedMinerPath(mPair));
                    if (Miner != null)
                    {
                        Miner.InitMiningSetup(new MiningSetup(miningPairs));
                        AlgorithmType = mPair.Algorithm.NiceHashID;
                    }
                }
            }
        }
コード例 #5
0
 public MiningDevice(ComputeDevice device)
 {
     Device = device;
     foreach (var algo in Device.GetAlgorithmSettings())
     {
         bool isAlgoMiningCapable = GroupSetupUtils.IsAlgoMiningCapable(algo);
         bool isValidMinerPath    = MinerPaths.IsValidMinerPath(algo.MinerBinaryPath);
         if (isAlgoMiningCapable && isValidMinerPath)
         {
             Algorithms.Add(algo);
         }
     }
 }
コード例 #6
0
 public MiningSetup(List <MiningPair> miningPairs)
 {
     this.IsInit = false;
     this.CurrentAlgorithmType = AlgorithmType.NONE;
     if (miningPairs != null && miningPairs.Count > 0)
     {
         this.MiningPairs = miningPairs;
         this.MiningPairs.Sort((a, b) => a.Device.ID - b.Device.ID);
         this.MinerName            = miningPairs[0].Algorithm.MinerName;
         this.CurrentAlgorithmType = miningPairs[0].Algorithm.NiceHashID;
         this.MinerPath            = miningPairs[0].Algorithm.MinerBinaryPath;
         this.IsInit = MinerPaths.IsValidMinerPath(this.MinerPath);
     }
 }
コード例 #7
0
 public MiningDevice(ComputeDevice device)
 {
     Device = device;
     foreach (var algo in Device.GetAlgorithmSettings())
     {
         var isAlgoMiningCapable = GroupSetupUtils.IsAlgoMiningCapable(algo);
         var isValidMinerPath    = MinerPaths.IsValidMinerPath(algo.MinerBinaryPath);
         if (isAlgoMiningCapable && isValidMinerPath)
         {
             Algorithms.Add(algo);
         }
     }
     MostProfitableAlgorithmType = AlgorithmType.NONE;
     MostProfitableMinerBaseType = MinerBaseType.NONE;
 }
コード例 #8
0
 public MiningSetup(List <MiningPair> miningPairs)
 {
     IsInit = false;
     CurrentAlgorithmType = AlgorithmType.NONE;
     if (miningPairs == null || miningPairs.Count <= 0)
     {
         return;
     }
     MiningPairs = miningPairs;
     MiningPairs.Sort((a, b) => a.Device.ID - b.Device.ID);
     MinerName                     = miningPairs[0].Algorithm.MinerName;
     CurrentAlgorithmType          = miningPairs[0].Algorithm.NiceHashID;
     CurrentSecondaryAlgorithmType = miningPairs[0].Algorithm.SecondaryNiceHashID;
     MinerPath                     = miningPairs[0].Algorithm.MinerBinaryPath;
     IsInit = MinerPaths.IsValidMinerPath(MinerPath);
 }
コード例 #9
0
ファイル: MiningSetup.cs プロジェクト: jerlis/NiceHashMiner
 public MiningSetup(List <MiningPair> miningPairs)
 {
     this.IsInit = false;
     this.CurrentAlgorithmType = AlgorithmType.NONE;
     if (miningPairs != null && miningPairs.Count > 0)
     {
         this.MinerPath = MinerPaths.GetOptimizedMinerPath(miningPairs[0]);
         if (this.MinerPath != MinerPaths.NONE)
         {
             this.MiningPairs = miningPairs;
             this.MiningPairs.Sort((a, b) => a.Device.ID - b.Device.ID);
             this.MinerName            = miningPairs[0].Algorithm.MinerName;
             this.CurrentAlgorithmType = miningPairs[0].Algorithm.NiceHashID;
             this.IsInit = true;
         }
     }
 }
コード例 #10
0
 public static bool ShouldGroup(MiningPair a, MiningPair b)
 {
     // group if same bin path and same algo type
     if (IsSameBinPath(a, b) && IsSameAlgorithmType(a, b))
     {
         AlgorithmType algorithmType = a.Algorithm.NiceHashID;
         // AlgorithmType.Equihash is special case
         if (AlgorithmType.Equihash == algorithmType)
         {
             string minerPath = MinerPaths.GetOptimizedMinerPath(a);
             return(EquihashGroup.IsEquihashGroupLogic(minerPath,
                                                       a, b));
         }
         // all other algorithms are grouped if DeviceType is same and is not CPU
         else if (IsNotCpuGroups(a, b) && IsSameDeviceType(a, b))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #11
0
 private static bool IsSameBinPath(MiningPair a, MiningPair b)
 {
     return(MinerPaths.GetOptimizedMinerPath(a)
            == MinerPaths.GetOptimizedMinerPath(b));
 }
コード例 #12
0
        public static Tuple <ComputeDevice, DeviceMiningStatus> GetDeviceMiningStatus(ComputeDevice device)
        {
            var status = DeviceMiningStatus.CanMine;

            if (device == null)
            {
                // C# is null happy
                status = DeviceMiningStatus.DeviceNull;
            }
            else if (device.Enabled == false)
            {
                status = DeviceMiningStatus.Disabled;
            }
            else
            {
                var hasEnabledAlgo = device.GetAlgorithmSettings().Aggregate(false,
                                                                             (current, algo) =>
                                                                             current | (IsAlgoMiningCapable(algo) && MinerPaths.IsValidMinerPath(algo.MinerBinaryPath)));
                if (hasEnabledAlgo == false)
                {
                    status = DeviceMiningStatus.NoEnabledAlgorithms;
                }
            }

            return(new Tuple <ComputeDevice, DeviceMiningStatus>(device, status));
        }
コード例 #13
0
 public static bool IsValidMinerPath(ComputeDevice device, Algorithm algo)
 {
     return(MinerPaths.NONE != MinerPaths.GetOptimizedMinerPath(device, algo));
 }