コード例 #1
0
ファイル: KernelOutputSet.cs プロジェクト: peakyuclub/ntminer
        private static void PickTotalShare(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string totalSharePattern = kernelOutput.TotalSharePattern;

            if (isDual)
            {
                totalSharePattern = kernelOutput.DualTotalSharePattern;
            }
            if (string.IsNullOrEmpty(totalSharePattern))
            {
                return;
            }
            var match = Regex.Match(input, totalSharePattern, RegexOptions.Compiled);

            if (match.Success)
            {
                string totalShareText = match.Groups["totalShare"].Value;
                int    totalShare;
                if (int.TryParse(totalShareText, out totalShare))
                {
                    ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                    root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: totalShare - share.RejectShareCount, rejectShareCount: null, now: DateTime.Now);
                }
            }
        }
コード例 #2
0
        private static void PickTotalShare(INTMinerContext root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string totalSharePattern = kernelOutput.TotalSharePattern;

            if (isDual)
            {
                totalSharePattern = kernelOutput.DualTotalSharePattern;
            }
            if (string.IsNullOrEmpty(totalSharePattern))
            {
                return;
            }
            Regex regex = VirtualRoot.GetRegex(totalSharePattern);
            var   match = regex.Match(input);

            if (match.Success)
            {
                string totalShareText = match.Groups[NTKeyword.TotalShareGroupName].Value;
                if (int.TryParse(totalShareText, out int totalShare))
                {
                    ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                    root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: totalShare - share.RejectShareCount, rejectShareCount: null, now: DateTime.Now);
                }
            }
        }
コード例 #3
0
        private static void PickAcceptOneShare(INTMinerContext root, IMineContext mineContext, string input, string preline, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string acceptOneShare = kernelOutput.AcceptOneShare;

            if (isDual)
            {
                acceptOneShare = kernelOutput.DualAcceptOneShare;
            }
            if (string.IsNullOrEmpty(acceptOneShare))
            {
                return;
            }
            if (acceptOneShare.Contains("\n"))
            {
                input = preline + "\n" + input;
            }
            Regex regex = VirtualRoot.GetRegex(acceptOneShare);
            var   match = regex.Match(input);

            if (match.Success)
            {
                if (!isDual)
                {
                    // 决定不支持双挖的单卡份额统计
                    string gpuText = match.Groups[NTKeyword.GpuIndexGroupName].Value;
                    if (!string.IsNullOrEmpty(gpuText))
                    {
                        if (int.TryParse(gpuText, out int gpuIndex))
                        {
                            if (kernelOutput.IsMapGpuIndex && !string.IsNullOrWhiteSpace(mineContext.KernelInput.DevicesArg))
                            {
                                if (mineContext.UseDevices.Length != 0 && mineContext.UseDevices.Length != root.GpuSet.Count && gpuIndex < mineContext.UseDevices.Length)
                                {
                                    gpuIndex = mineContext.UseDevices[gpuIndex];
                                }
                            }
                            if (string.IsNullOrEmpty(kernelOutput.FoundOneShare))
                            {
                                root.GpusSpeed.IncreaseFoundShare(gpuIndex);
                            }
                            root.GpusSpeed.IncreaseAcceptShare(gpuIndex);
                        }
                    }
                }
                ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: share.AcceptShareCount + 1, rejectShareCount: null, now: DateTime.Now);
            }
        }
コード例 #4
0
ファイル: KernelSet.cs プロジェクト: TimeYM/ntminer
        private static void PickRejectPattern(INTMinerRoot root, string input, IKernel kernel, ICoin coin, bool isDual)
        {
            string rejectSharePattern = kernel.RejectSharePattern;

            if (isDual)
            {
                rejectSharePattern = kernel.DualRejectSharePattern;
            }
            if (string.IsNullOrEmpty(rejectSharePattern))
            {
                return;
            }
            var match = Regex.Match(input, rejectSharePattern);

            if (match.Success)
            {
                string rejectShareText = match.Groups["rejectShare"].Value;

                int rejectShare;
                if (int.TryParse(rejectShareText, out rejectShare))
                {
                    ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                    share.RejectCount = rejectShare;
                    share.ShareOn     = DateTime.Now;
                    Global.Happened(new ShareChangedEvent(share));
                }
            }
        }
コード例 #5
0
ファイル: KernelOutputSet.cs プロジェクト: peakyuclub/ntminer
        private static void PickRejectPattern(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string rejectSharePattern = kernelOutput.RejectSharePattern;

            if (isDual)
            {
                rejectSharePattern = kernelOutput.DualRejectSharePattern;
            }
            if (string.IsNullOrEmpty(rejectSharePattern))
            {
                return;
            }
            var match = Regex.Match(input, rejectSharePattern, RegexOptions.Compiled);

            if (match.Success)
            {
                string rejectShareText = match.Groups["rejectShare"].Value;

                int rejectShare;
                if (int.TryParse(rejectShareText, out rejectShare))
                {
                    root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: null, rejectShareCount: rejectShare, now: DateTime.Now);
                }
            }
        }
コード例 #6
0
ファイル: KernelOutputSet.cs プロジェクト: yuanaichi/ntminer
        private static void PickAcceptShare(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string acceptSharePattern = kernelOutput.AcceptSharePattern;

            if (isDual)
            {
                acceptSharePattern = kernelOutput.DualAcceptSharePattern;
            }
            if (string.IsNullOrEmpty(acceptSharePattern))
            {
                return;
            }
            var match = Regex.Match(input, acceptSharePattern, RegexOptions.Compiled);

            if (match.Success)
            {
                if (!isDual)
                {
                }
                string acceptShareText = match.Groups[Consts.AcceptShareGroupName].Value;
                int    acceptShare;
                if (int.TryParse(acceptShareText, out acceptShare))
                {
                    root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: acceptShare, rejectShareCount: null, now: DateTime.Now);
                }
            }
        }
コード例 #7
0
        private void Init(INTMinerContext root)
        {
            var minerProfileRepository = root.ServerContext.CreateLocalRepository <MinerProfileData>();

            _data = minerProfileRepository.GetAll().FirstOrDefault();
            var mineWorkRepository = root.ServerContext.CreateLocalRepository <MineWorkData>();

            MineWork = mineWorkRepository.GetAll().FirstOrDefault();
            if (_data == null)
            {
                Guid  coinId = Guid.Empty;
                ICoin coin   = root.ServerContext.CoinSet.AsEnumerable().OrderBy(a => a.Code).FirstOrDefault();
                if (coin != null)
                {
                    coinId = coin.GetId();
                }
                _data = MinerProfileData.CreateDefaultData(coinId);
            }
            else
            {
                // 交换到注册表以供守护进程访问
                if (ClientAppType.IsMinerClient && !NTMinerContext.IsJsonLocal)
                {
                    SetIsOuterUserEnabled(_data.IsOuterUserEnabled);
                    SetOuterUserId(_data.OuterUserId);
                }
            }
            if (_coinProfileSet == null)
            {
                _coinProfileSet = new CoinProfileSet(root);
            }
            else
            {
                _coinProfileSet.Refresh();
            }
            if (_coinKernelProfileSet == null)
            {
                _coinKernelProfileSet = new CoinKernelProfileSet(root);
            }
            else
            {
                _coinKernelProfileSet.Refresh();
            }
            if (_poolProfileSet == null)
            {
                _poolProfileSet = new PoolProfileSet(root);
            }
            else
            {
                _poolProfileSet.Refresh();
            }
            if (_walletSet == null)
            {
                _walletSet = new WalletSet(root);
            }
            else
            {
                _walletSet.Refresh();
            }
        }
コード例 #8
0
        private static void PickRejectPattern(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string rejectSharePattern = kernelOutput.RejectSharePattern;

            if (isDual)
            {
                rejectSharePattern = kernelOutput.DualRejectSharePattern;
            }
            if (string.IsNullOrEmpty(rejectSharePattern))
            {
                return;
            }
            Regex regex = VirtualRoot.GetRegex(rejectSharePattern);
            var   match = regex.Match(input);

            if (match.Success)
            {
                string rejectShareText = match.Groups[NTKeyword.RejectShareGroupName].Value;

                if (int.TryParse(rejectShareText, out int rejectShare))
                {
                    root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: null, rejectShareCount: rejectShare, now: DateTime.Now);
                }
            }
        }
コード例 #9
0
ファイル: KernelOutputSet.cs プロジェクト: piaoyun/ntminer
        private static void PickAcceptShare(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string acceptSharePattern = kernelOutput.AcceptSharePattern;

            if (isDual)
            {
                acceptSharePattern = kernelOutput.DualAcceptSharePattern;
            }
            if (string.IsNullOrEmpty(acceptSharePattern))
            {
                return;
            }
            var match = Regex.Match(input, acceptSharePattern);

            if (match.Success)
            {
                string acceptShareText = match.Groups["acceptShare"].Value;
                int    acceptShare;
                if (int.TryParse(acceptShareText, out acceptShare))
                {
                    ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                    share.AcceptShareCount = acceptShare;
                    share.ShareOn          = DateTime.Now;
                    Global.Happened(new ShareChangedEvent(share));
                }
            }
        }
コード例 #10
0
ファイル: CoinProfileSet.cs プロジェクト: TimeYM/ntminer
 private CoinProfile(INTMinerRoot root, ICoin coin)
 {
     _root = root;
     _data = GetCoinProfileData(coin.GetId());
     if (_data == null)
     {
         throw new ValidationException("未获取到CoinProfileData数据,请重试");
     }
 }
コード例 #11
0
ファイル: MinerProfile.cs プロジェクト: bentiancai629/ntminer
 private void Init(INTMinerRoot root, MineWorkData mineWorkData)
 {
     MineWork  = mineWorkData;
     isUseJson = mineWorkData != null;
     if (isUseJson)
     {
         _data = NTMinerRoot.LocalJson.MinerProfile;
     }
     else
     {
         IRepository <MinerProfileData> repository = NTMinerRoot.CreateLocalRepository <MinerProfileData>(false);
         _data = repository.GetAll().FirstOrDefault();
     }
     if (_data == null)
     {
         Guid  coinId = Guid.Empty;
         ICoin coin   = root.CoinSet.OrderBy(a => a.SortNumber).FirstOrDefault();
         if (coin != null)
         {
             coinId = coin.GetId();
         }
         _data = MinerProfileData.CreateDefaultData(coinId);
     }
     if (_coinProfileSet == null)
     {
         _coinProfileSet = new CoinProfileSet(root, mineWorkData);
     }
     else
     {
         _coinProfileSet.Refresh(mineWorkData);
     }
     if (_coinKernelProfileSet == null)
     {
         _coinKernelProfileSet = new CoinKernelProfileSet(root, mineWorkData);
     }
     else
     {
         _coinKernelProfileSet.Refresh(mineWorkData);
     }
     if (_poolProfileSet == null)
     {
         _poolProfileSet = new PoolProfileSet(root, mineWorkData);
     }
     else
     {
         _poolProfileSet.Refresh(mineWorkData);
     }
     if (_walletSet == null)
     {
         _walletSet = new WalletSet(root);
     }
     else
     {
         _walletSet.Refresh();
     }
 }
コード例 #12
0
                /// <summary>
                /// 选择默认内核
                /// </summary>
                /// <param name="coin"></param>
                /// <returns></returns>
                private static Guid GetDefaultCoinKernelId(ICoin coin)
                {
                    var  root         = NTMinerRoot.Instance;
                    Guid coinKernelId = Guid.Empty;
                    bool noneGpu      = false;

                    if (root.GpuSet.GpuType == GpuType.Empty)
                    {
                        noneGpu = true;
                    }
                    List <ICoinKernel> coinKernels;

                    if (noneGpu)
                    {
                        coinKernels = root.CoinKernelSet.Where(a => a.CoinId == coin.GetId()).ToList();
                    }
                    else
                    {
                        coinKernels = root.CoinKernelSet.Where(a => a.CoinId == coin.GetId() && a.SupportedGpu.IsSupportedGpu(root.GpuSet.GpuType)).ToList();
                    }
                    var items = new List <Tuple <Guid, IKernel> >(coinKernels.Count);

                    foreach (var item in coinKernels)
                    {
                        if (root.KernelSet.TryGetKernel(item.KernelId, out IKernel kernel))
                        {
                            items.Add(new Tuple <Guid, IKernel>(item.GetId(), kernel));
                        }
                    }
                    items = items.OrderBy(a => a.Item2.Code).ThenByDescending(a => a.Item2.Version).ToList();
                    Guid kernelBrandId = coin.GetKernelBrandId(root.GpuSet.GpuType);

                    if (kernelBrandId == Guid.Empty)
                    {
                        coinKernelId = items.Select(a => a.Item1).FirstOrDefault();
                    }
                    else
                    {
                        coinKernelId = items.Where(a => a.Item2.BrandId == kernelBrandId).Select(a => a.Item1).FirstOrDefault();
                    }
                    return(coinKernelId);
                }
コード例 #13
0
ファイル: CoinViewModel.cs プロジェクト: piaoyun/ntminer
 public CoinViewModel(ICoin data) : this(data.GetId())
 {
     _code               = data.Code;
     _sortNumber         = data.SortNumber;
     _algo               = data.Algo;
     _testWallet         = data.TestWallet;
     _enName             = data.EnName;
     _cnName             = data.CnName;
     _walletRegexPattern = data.WalletRegexPattern;
     _justAsDualCoin     = data.JustAsDualCoin;
 }
コード例 #14
0
        private static void PickAcceptOneShare(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string acceptOneShare = kernelOutput.AcceptOneShare;

            if (isDual)
            {
                acceptOneShare = kernelOutput.DualAcceptOneShare;
            }
            if (string.IsNullOrEmpty(acceptOneShare))
            {
                return;
            }
            var match = Regex.Match(input, acceptOneShare);

            if (match.Success)
            {
                ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: share.AcceptShareCount + 1, rejectShareCount: null, now: DateTime.Now);
            }
        }
コード例 #15
0
ファイル: KernelOutputSet.cs プロジェクト: peakyuclub/ntminer
        private static void PickRejectOneShare(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string rejectOneShare = kernelOutput.RejectOneShare;

            if (isDual)
            {
                rejectOneShare = kernelOutput.DualRejectOneShare;
            }
            if (string.IsNullOrEmpty(rejectOneShare))
            {
                return;
            }
            var match = Regex.Match(input, rejectOneShare, RegexOptions.Compiled);

            if (match.Success)
            {
                ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                root.CoinShareSet.UpdateShare(coin.GetId(), null, share.RejectShareCount + 1, DateTime.Now);
            }
        }
コード例 #16
0
ファイル: KernelOutputSet.cs プロジェクト: yuanaichi/ntminer
        private static void PickRejectOneShare(INTMinerRoot root, string input, string preline, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string rejectOneShare = kernelOutput.RejectOneShare;

            if (isDual)
            {
                rejectOneShare = kernelOutput.DualRejectOneShare;
            }
            if (string.IsNullOrEmpty(rejectOneShare))
            {
                return;
            }
            if (rejectOneShare.Contains("\n"))
            {
                input = preline + "\n" + input;
            }
            var match = Regex.Match(input, rejectOneShare, RegexOptions.Compiled);

            if (match.Success)
            {
                if (!isDual)
                {
                    // 决定不支持双挖的单卡份额统计
                    string gpuText = match.Groups[Consts.GpuIndexGroupName].Value;
                    if (!string.IsNullOrEmpty(gpuText))
                    {
                        if (int.TryParse(gpuText, out int gpuIndex))
                        {
                            if (string.IsNullOrEmpty(kernelOutput.FoundOneShare))
                            {
                                root.GpusSpeed.IncreaseFoundShare(gpuIndex);
                            }
                            root.GpusSpeed.IncreaseRejectShare(gpuIndex);
                        }
                    }
                }
                ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                root.CoinShareSet.UpdateShare(coin.GetId(), null, share.RejectShareCount + 1, DateTime.Now);
            }
        }
コード例 #17
0
        private static void PickRejectPercent(INTMinerContext root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string rejectPercentPattern = kernelOutput.RejectPercentPattern;

            if (isDual)
            {
                rejectPercentPattern = kernelOutput.DualRejectPercentPattern;
            }
            if (string.IsNullOrEmpty(rejectPercentPattern))
            {
                return;
            }
            Regex  regex             = VirtualRoot.GetRegex(rejectPercentPattern);
            var    match             = regex.Match(input);
            string rejectPercentText = match.Groups[NTKeyword.RejectPercentGroupName].Value;

            if (double.TryParse(rejectPercentText, out double rejectPercent))
            {
                ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: null, rejectShareCount: (int)(share.TotalShareCount * rejectPercent), now: DateTime.Now);
            }
        }
コード例 #18
0
ファイル: KernelOutputSet.cs プロジェクト: peakyuclub/ntminer
        private static void PickRejectPercent(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string rejectPercentPattern = kernelOutput.RejectPercentPattern;

            if (isDual)
            {
                rejectPercentPattern = kernelOutput.DualRejectPercentPattern;
            }
            if (string.IsNullOrEmpty(rejectPercentPattern))
            {
                return;
            }
            var    match             = Regex.Match(input, rejectPercentPattern, RegexOptions.Compiled);
            string rejectPercentText = match.Groups["rejectPercent"].Value;
            double rejectPercent;

            if (double.TryParse(rejectPercentText, out rejectPercent))
            {
                ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                root.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: null, rejectShareCount: (int)(share.TotalShareCount * rejectPercent), now: DateTime.Now);
            }
        }
コード例 #19
0
        private void Init(INTMinerRoot root)
        {
            IRepository <MinerProfileData> minerProfileRepository = NTMinerRoot.CreateLocalRepository <MinerProfileData>();

            _data = minerProfileRepository.GetAll().FirstOrDefault();
            IRepository <MineWorkData> mineWorkRepository = NTMinerRoot.CreateLocalRepository <MineWorkData>();

            MineWork = mineWorkRepository.GetAll().FirstOrDefault();
            if (_data == null)
            {
                Guid  coinId = Guid.Empty;
                ICoin coin   = root.CoinSet.OrderBy(a => a.Code).FirstOrDefault();
                if (coin != null)
                {
                    coinId = coin.GetId();
                }
                _data = MinerProfileData.CreateDefaultData(coinId);
            }
            if (_coinProfileSet == null)
            {
                _coinProfileSet = new CoinProfileSet(root);
            }
            else
            {
                _coinProfileSet.Refresh();
            }
            if (_coinKernelProfileSet == null)
            {
                _coinKernelProfileSet = new CoinKernelProfileSet(root);
            }
            else
            {
                _coinKernelProfileSet.Refresh();
            }
            if (_poolProfileSet == null)
            {
                _poolProfileSet = new PoolProfileSet(root);
            }
            else
            {
                _poolProfileSet.Refresh();
            }
            if (_walletSet == null)
            {
                _walletSet = new WalletSet(root);
            }
            else
            {
                _walletSet.Refresh();
            }
        }
コード例 #20
0
        public static bool IsSupported(this IKernel kernel, ICoin coin)
        {
            // 群控客户端和无显卡的电脑的GpuSet类型都是空
            if (NTMinerContext.Instance.GpuSet.GpuType == GpuType.Empty)
            {
                return(true);
            }
            var coinKernelSet = NTMinerContext.Instance.ServerContext.CoinKernelSet;

            foreach (var item in coinKernelSet.AsEnumerable().Where(a => a.CoinId == coin.GetId() && a.KernelId == kernel.GetId()).ToArray())
            {
                if (item.SupportedGpu.IsSupportedGpu(NTMinerContext.Instance.GpuSet.GpuType))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #21
0
ファイル: CoinViewModel.cs プロジェクト: suifengtec/NtMiner
 public CoinViewModel(ICoin data) : this(data.GetId()) {
     _code = data.Code;
     _algoId = data.AlgoId;
     _testWallet = data.TestWallet;
     _enName = data.EnName;
     _cnName = data.CnName;
     _icon = data.Icon;
     _walletRegexPattern = data.WalletRegexPattern;
     _justAsDualCoin = data.JustAsDualCoin;
     _notice = data.Notice;
     _tutorialUrl = data.TutorialUrl;
     _isHot = data.IsHot;
     _kernelBrand = data.KernelBrand;
     _minGpuMemoryGb = data.MinGpuMemoryGb;
     string iconFileFullName = MinerClientTempPath.GetIconFileFullName(data.Icon);
     if (!string.IsNullOrEmpty(iconFileFullName) && File.Exists(iconFileFullName)) {
         _iconImageSource = iconFileFullName;
     }
 }
コード例 #22
0
        public CoinViewModel(ICoin data) : this(data.GetId())
        {
            _code               = data.Code;
            _sortNumber         = data.SortNumber;
            _algoId             = data.AlgoId;
            _testWallet         = data.TestWallet;
            _enName             = data.EnName;
            _cnName             = data.CnName;
            _icon               = data.Icon;
            _walletRegexPattern = data.WalletRegexPattern;
            _justAsDualCoin     = data.JustAsDualCoin;
            _notice             = data.Notice;
            string iconFileFullName = SpecialPath.GetIconFileFullName(data);

            if (!string.IsNullOrEmpty(iconFileFullName) && File.Exists(iconFileFullName))
            {
                _iconImageSource = iconFileFullName;
            }
        }
コード例 #23
0
ファイル: KernelOutputSet.cs プロジェクト: piaoyun/ntminer
        private static void PickRejectPercent(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string rejectPercentPattern = kernelOutput.RejectPercentPattern;

            if (isDual)
            {
                rejectPercentPattern = kernelOutput.DualRejectPercentPattern;
            }
            if (string.IsNullOrEmpty(rejectPercentPattern))
            {
                return;
            }
            var    match             = Regex.Match(input, rejectPercentPattern);
            string rejectPercentText = match.Groups["rejectPercent"].Value;
            double rejectPercent;

            if (double.TryParse(rejectPercentText, out rejectPercent))
            {
                ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                share.RejectCount = (int)(share.TotalShareCount * rejectPercent);
                share.ShareOn     = DateTime.Now;
                Global.Happened(new ShareChangedEvent(share));
            }
        }
コード例 #24
0
        private static void PickAcceptShare(INTMinerContext context, string line, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string acceptSharePattern = kernelOutput.AcceptSharePattern;

            if (isDual)
            {
                acceptSharePattern = kernelOutput.DualAcceptSharePattern;
            }
            if (string.IsNullOrEmpty(acceptSharePattern))
            {
                return;
            }
            Regex regex = VirtualRoot.GetRegex(acceptSharePattern);
            var   match = regex.Match(line);

            if (match.Success)
            {
                string acceptShareText = match.Groups[NTKeyword.AcceptShareGroupName].Value;
                if (int.TryParse(acceptShareText, out int acceptShare))
                {
                    context.CoinShareSet.UpdateShare(coin.GetId(), acceptShareCount: acceptShare, rejectShareCount: null, now: DateTime.Now);
                }
            }
        }
コード例 #25
0
        private static void PickRejectOneShare(INTMinerContext root, IMineContext mineContext, string input, string preline, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string rejectOneShare = kernelOutput.RejectOneShare;

            if (isDual)
            {
                rejectOneShare = kernelOutput.DualRejectOneShare;
            }
            if (string.IsNullOrEmpty(rejectOneShare))
            {
                return;
            }
            if (rejectOneShare.Contains("\n"))
            {
                input = preline + "\n" + input;
            }
            Regex regex = VirtualRoot.GetRegex(rejectOneShare);
            var   match = regex.Match(input);

            if (match.Success)
            {
                if (!isDual)
                {
                    // 决定不支持双挖的单卡份额统计
                    string gpuText = match.Groups[NTKeyword.GpuIndexGroupName].Value;
                    if (!string.IsNullOrEmpty(gpuText))
                    {
                        if (int.TryParse(gpuText, out int gpuIndex))
                        {
                            if (kernelOutput.IsMapGpuIndex && !string.IsNullOrWhiteSpace(mineContext.KernelInput.DevicesArg))
                            {
                                if (mineContext.UseDevices.Length != 0 && mineContext.UseDevices.Length != root.GpuSet.Count && gpuIndex < mineContext.UseDevices.Length)
                                {
                                    gpuIndex = mineContext.UseDevices[gpuIndex];
                                }
                            }
                            if (string.IsNullOrEmpty(kernelOutput.FoundOneShare))
                            {
                                root.GpusSpeed.IncreaseFoundShare(gpuIndex);
                            }
                            root.GpusSpeed.IncreaseRejectShare(gpuIndex);
                        }
                    }
                    else if (!string.IsNullOrEmpty(kernelOutput.FoundOneShare))
                    {
                        // 哪个GPU最近找到了一个share就是那个GPU拒绝了一个share
                        var       gpuSpeeds = root.GpusSpeed.AsEnumerable();
                        IGpuSpeed gpuSpeed  = null;
                        foreach (var item in gpuSpeeds)
                        {
                            if (gpuSpeed == null)
                            {
                                gpuSpeed = item;
                            }
                            else if (item.FoundShareOn > gpuSpeed.FoundShareOn)
                            {
                                gpuSpeed = item;
                            }
                        }
                        if (gpuSpeed != null)
                        {
                            var gpuIndex = gpuSpeed.Gpu.Index;
                            root.GpusSpeed.IncreaseRejectShare(gpuIndex);
                        }
                    }
                }
                ICoinShare share = root.CoinShareSet.GetOrCreate(coin.GetId());
                root.CoinShareSet.UpdateShare(coin.GetId(), null, share.RejectShareCount + 1, DateTime.Now);
            }
        }
コード例 #26
0
ファイル: CoinExtensions.cs プロジェクト: ranchenglou/ntminer
        public static bool IsSupported(this ICoin coin)
        {
            foreach (var coinKernel in NTMinerRoot.Current.CoinKernelSet.Where(a => a.CoinId == coin.GetId()))
            {
                if (coinKernel.SupportedGpu == Gpus.SupportedGpu.Both)
                {
                    return(true);
                }
                if (coinKernel.SupportedGpu == Gpus.SupportedGpu.NVIDIA && NTMinerRoot.Current.GpuSet.GpuType == Gpus.GpuType.NVIDIA)
                {
                    return(true);
                }
                if (coinKernel.SupportedGpu == Gpus.SupportedGpu.AMD && NTMinerRoot.Current.GpuSet.GpuType == Gpus.GpuType.AMD)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #27
0
 public static bool IsSupported(this IKernel kernel, ICoin coin)
 {
     if (VirtualRoot.IsMinerStudio)
     {
         return(true);
     }
     foreach (var item in NTMinerRoot.Current.CoinKernelSet.Where(a => a.CoinId == coin.GetId() && a.KernelId == kernel.GetId()))
     {
         if (item.SupportedGpu == SupportedGpu.Both)
         {
             return(true);
         }
         if (item.SupportedGpu == SupportedGpu.NVIDIA && NTMinerRoot.Current.GpuSet.GpuType == GpuType.NVIDIA)
         {
             return(true);
         }
         if (item.SupportedGpu == SupportedGpu.AMD && NTMinerRoot.Current.GpuSet.GpuType == GpuType.AMD)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #28
0
ファイル: KernelExtensions.cs プロジェクト: wind959/ntminer
 public static bool IsSupported(this IKernel kernel, ICoin coin)
 {
     // 群控客户端和无显卡的电脑的GpuSet类型都是空
     if (NTMinerRoot.Instance.GpuSet.GpuType == GpuType.Empty)
     {
         return(true);
     }
     foreach (var item in NTMinerRoot.Instance.CoinKernelSet.Where(a => a.CoinId == coin.GetId() && a.KernelId == kernel.GetId()))
     {
         if (item.SupportedGpu.IsSupportedGpu(NTMinerRoot.Instance.GpuSet.GpuType))
         {
             return(true);
         }
     }
     return(false);
 }