示例#1
0
        public string BuildAssembleArgs(out Dictionary <string, string> parameters, out Dictionary <Guid, string> fileWriters, out Dictionary <Guid, string> fragments)
        {
            parameters  = new Dictionary <string, string>();
            fileWriters = new Dictionary <Guid, string>();
            fragments   = new Dictionary <Guid, string>();
            if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out ICoin mainCoin))
            {
                return(string.Empty);
            }
            ICoinProfile coinProfile = this.MinerProfile.GetCoinProfile(mainCoin.GetId());

            if (!PoolSet.TryGetPool(coinProfile.PoolId, out IPool mainCoinPool))
            {
                return(string.Empty);
            }
            if (!CoinKernelSet.TryGetCoinKernel(coinProfile.CoinKernelId, out ICoinKernel coinKernel))
            {
                return(string.Empty);
            }
            if (!KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel))
            {
                return(string.Empty);
            }
            if (!kernel.IsSupported(mainCoin))
            {
                return(string.Empty);
            }
            if (!KernelInputSet.TryGetKernelInput(kernel.KernelInputId, out IKernelInput kernelInput))
            {
                return(string.Empty);
            }
            ICoinKernelProfile coinKernelProfile = this.MinerProfile.GetCoinKernelProfile(coinProfile.CoinKernelId);
            string             poolKernelArgs    = string.Empty;
            IPoolKernel        poolKernel        = PoolKernelSet.FirstOrDefault(a => a.PoolId == mainCoinPool.GetId() && a.KernelId == kernel.GetId());

            if (poolKernel != null)
            {
                poolKernelArgs = poolKernel.Args;
            }
            string kernelArgs     = kernelInput.Args;
            string coinKernelArgs = coinKernel.Args;
            string customArgs     = coinKernelProfile.CustomArgs;

            parameters.Add("mainCoin", mainCoin.Code);
            if (mainCoinPool.IsUserMode)
            {
                IPoolProfile poolProfile = MinerProfile.GetPoolProfile(mainCoinPool.GetId());
                string       password    = poolProfile.Password;
                if (string.IsNullOrEmpty(password))
                {
                    password = "******";
                }
                parameters.Add("userName", poolProfile.UserName);
                parameters.Add("password", password);
            }
            else
            {
                parameters.Add("wallet", coinProfile.Wallet);
            }
            parameters.Add("host", mainCoinPool.GetHost());
            parameters.Add("port", mainCoinPool.GetPort().ToString());
            parameters.Add("pool", mainCoinPool.Server);
            parameters.Add("worker", this.MinerProfile.MinerName);
            if (coinKernel.IsSupportPool1)
            {
                parameters.Add("worker1", this.MinerProfile.MinerName);
                if (PoolSet.TryGetPool(coinProfile.PoolId1, out IPool mainCoinPool1))
                {
                    parameters.Add("host1", mainCoinPool1.GetHost());
                    parameters.Add("port1", mainCoinPool1.GetPort().ToString());
                    parameters.Add("pool1", mainCoinPool1.Server);
                    if (mainCoinPool1.IsUserMode)
                    {
                        IPoolProfile poolProfile1 = MinerProfile.GetPoolProfile(mainCoinPool1.GetId());
                        string       password1    = poolProfile1.Password;
                        if (string.IsNullOrEmpty(password1))
                        {
                            password1 = "x";
                        }
                        parameters.Add("userName1", poolProfile1.UserName);
                        parameters.Add("password1", password1);
                    }
                    else
                    {
                        parameters.Add("wallet1", coinProfile.Wallet);
                    }
                }
            }
            // 这里不要考虑{logfile},{logfile}往后推迟
            if (coinKernelProfile.IsDualCoinEnabled && kernelInput.IsSupportDualMine)
            {
                Guid dualCoinGroupId = coinKernel.DualCoinGroupId;
                if (dualCoinGroupId == Guid.Empty)
                {
                    dualCoinGroupId = kernelInput.DualCoinGroupId;
                }
                if (dualCoinGroupId != Guid.Empty)
                {
                    if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out ICoin dualCoin))
                    {
                        ICoinProfile dualCoinProfile = this.MinerProfile.GetCoinProfile(dualCoin.GetId());
                        if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out IPool dualCoinPool))
                        {
                            IPoolProfile dualPoolProfile = MinerProfile.GetPoolProfile(dualCoinPool.GetId());
                            string       dualPassword    = dualPoolProfile.Password;
                            if (string.IsNullOrEmpty(dualPassword))
                            {
                                dualPassword = "******";
                            }
                            parameters.Add("dualCoin", dualCoin.Code);
                            parameters.Add("dualWallet", dualCoinProfile.DualCoinWallet);
                            parameters.Add("dualUserName", dualPoolProfile.UserName);
                            parameters.Add("dualPassword", dualPassword);
                            parameters.Add("dualHost", dualCoinPool.GetHost());
                            parameters.Add("dualPort", dualCoinPool.GetPort().ToString());
                            parameters.Add("dualPool", dualCoinPool.Server);

                            kernelArgs = kernelInput.DualFullArgs;
                            AssembleArgs(parameters, ref kernelArgs, isDual: true);
                            AssembleArgs(parameters, ref poolKernelArgs, isDual: true);
                            AssembleArgs(parameters, ref customArgs, isDual: true);

                            string dualWeightArg;
                            if (!string.IsNullOrEmpty(kernelInput.DualWeightArg))
                            {
                                if (coinKernelProfile.IsAutoDualWeight && kernelInput.IsAutoDualWeight)
                                {
                                    dualWeightArg = string.Empty;
                                }
                                else
                                {
                                    dualWeightArg = $"{kernelInput.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}";
                                }
                            }
                            else
                            {
                                dualWeightArg = string.Empty;
                            }
                            StringBuilder dualSb = new StringBuilder();
                            dualSb.Append(kernelArgs);
                            if (!string.IsNullOrEmpty(dualWeightArg))
                            {
                                dualSb.Append(" ").Append(dualWeightArg);
                            }
                            if (!string.IsNullOrEmpty(poolKernelArgs))
                            {
                                dualSb.Append(" ").Append(poolKernelArgs);
                            }
                            BuildFragments(coinKernel, parameters, out fileWriters, out fragments);
                            foreach (var fragment in fragments.Values)
                            {
                                dualSb.Append(" ").Append(fragment);
                            }
                            if (!string.IsNullOrEmpty(customArgs))
                            {
                                dualSb.Append(" ").Append(customArgs);
                            }

                            // 注意:这里退出
                            return(dualSb.ToString());
                        }
                    }
                }
            }
            AssembleArgs(parameters, ref kernelArgs, isDual: false);
            AssembleArgs(parameters, ref coinKernelArgs, isDual: false);
            AssembleArgs(parameters, ref poolKernelArgs, isDual: false);
            AssembleArgs(parameters, ref customArgs, isDual: false);
            string devicesArgs = string.Empty;

            if (!string.IsNullOrWhiteSpace(kernelInput.DevicesArg))
            {
                List <int> useDevices = this.GpuSet.GetUseDevices();
                if (useDevices.Count != 0 && useDevices.Count != GpuSet.Count)
                {
                    string separator = kernelInput.DevicesSeparator;
                    if (kernelInput.DevicesSeparator == "space")
                    {
                        separator = " ";
                    }
                    if (string.IsNullOrEmpty(separator))
                    {
                        List <string> gpuIndexes = new List <string>();
                        foreach (var index in useDevices)
                        {
                            int i = index;
                            if (kernelInput.DeviceBaseIndex != 0)
                            {
                                i = index + kernelInput.DeviceBaseIndex;
                            }
                            if (i > 9)
                            {
                                gpuIndexes.Add(gpuIndexChars[i - 10]);
                            }
                            else
                            {
                                gpuIndexes.Add(i.ToString());
                            }
                        }
                        devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, gpuIndexes)}";
                    }
                    else
                    {
                        devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, useDevices)}";
                    }
                }
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(kernelArgs);
            if (!string.IsNullOrEmpty(coinKernelArgs))
            {
                sb.Append(" ").Append(coinKernelArgs);
            }
            if (!string.IsNullOrEmpty(poolKernelArgs))
            {
                sb.Append(" ").Append(poolKernelArgs);
            }
            if (!string.IsNullOrEmpty(devicesArgs))
            {
                sb.Append(" ").Append(devicesArgs);
            }
            BuildFragments(coinKernel, parameters, out fileWriters, out fragments);
            foreach (var fragment in fragments.Values)
            {
                sb.Append(" ").Append(fragment);
            }
            if (!string.IsNullOrEmpty(customArgs))
            {
                sb.Append(" ").Append(customArgs);
            }

            return(sb.ToString());
        }
示例#2
0
        public string BuildAssembleArgs(out Dictionary <string, string> parameters, out Dictionary <Guid, string> fileWriters, out Dictionary <Guid, string> fragments)
        {
            parameters  = new Dictionary <string, string>();
            fileWriters = new Dictionary <Guid, string>();
            fragments   = new Dictionary <Guid, string>();
            if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out ICoin mainCoin))
            {
                return(string.Empty);
            }
            ICoinProfile coinProfile = this.MinerProfile.GetCoinProfile(mainCoin.GetId());

            if (!PoolSet.TryGetPool(coinProfile.PoolId, out IPool mainCoinPool))
            {
                return(string.Empty);
            }
            if (!CoinKernelSet.TryGetCoinKernel(coinProfile.CoinKernelId, out ICoinKernel coinKernel))
            {
                return(string.Empty);
            }
            if (!KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel))
            {
                return(string.Empty);
            }
            if (!kernel.IsSupported(mainCoin))
            {
                return(string.Empty);
            }
            if (!KernelInputSet.TryGetKernelInput(kernel.KernelInputId, out IKernelInput kernelInput))
            {
                return(string.Empty);
            }
            ICoinKernelProfile coinKernelProfile = this.MinerProfile.GetCoinKernelProfile(coinProfile.CoinKernelId);
            string             poolKernelArgs    = string.Empty;
            IPoolKernel        poolKernel        = PoolKernelSet.FirstOrDefault(a => a.PoolId == mainCoinPool.GetId() && a.KernelId == kernel.GetId());

            if (poolKernel != null)
            {
                poolKernelArgs = poolKernel.Args;
            }
            string kernelArgs     = kernelInput.Args;
            string coinKernelArgs = coinKernel.Args;
            string customArgs     = coinKernelProfile.CustomArgs ?? string.Empty;

            parameters.Add(Consts.MainCoinParameterName, mainCoin.Code);
            if (mainCoinPool.IsUserMode)
            {
                IPoolProfile poolProfile = MinerProfile.GetPoolProfile(mainCoinPool.GetId());
                string       password    = poolProfile.Password;
                if (string.IsNullOrEmpty(password))
                {
                    password = Consts.PasswordDefaultValue;
                }
                parameters.Add(Consts.UserNameParameterName, poolProfile.UserName);
                parameters.Add(Consts.PasswordParameterName, password);
                parameters.Add(Consts.WalletParameterName, poolProfile.UserName);
            }
            else
            {
                parameters.Add(Consts.WalletParameterName, coinProfile.Wallet);
            }
            parameters.Add(Consts.HostParameterName, mainCoinPool.GetHost());
            parameters.Add(Consts.PortParameterName, mainCoinPool.GetPort().ToString());
            parameters.Add(Consts.PoolParameterName, mainCoinPool.Server);
            string minerName = $"{mainCoinPool.MinerNamePrefix}{this.MinerProfile.MinerName}{mainCoinPool.MinerNamePostfix}";

            parameters.Add(Consts.WorkerParameterName, minerName);
            if (coinKernel.IsSupportPool1 && !mainCoinPool.NoPool1)
            {
                parameters.Add(Consts.Worker1ParameterName, minerName);
                if (PoolSet.TryGetPool(coinProfile.PoolId1, out IPool mainCoinPool1))
                {
                    parameters.Add(Consts.Host1ParameterName, mainCoinPool1.GetHost());
                    parameters.Add(Consts.Port1ParameterName, mainCoinPool1.GetPort().ToString());
                    parameters.Add(Consts.Pool1ParameterName, mainCoinPool1.Server);
                    if (mainCoinPool1.IsUserMode)
                    {
                        IPoolProfile poolProfile1 = MinerProfile.GetPoolProfile(mainCoinPool1.GetId());
                        string       password1    = poolProfile1.Password;
                        if (string.IsNullOrEmpty(password1))
                        {
                            password1 = Consts.PasswordDefaultValue;
                        }
                        parameters.Add(Consts.UserName1ParameterName, poolProfile1.UserName);
                        parameters.Add(Consts.Password1ParameterName, password1);
                    }
                    else
                    {
                        parameters.Add(Consts.Wallet1ParameterName, coinProfile.Wallet);
                    }
                }
            }
            string devicesArgs = GetDevicesArgs(kernelInput);

            // 这里不要考虑{logfile},{logfile}往后推迟
            if (coinKernelProfile.IsDualCoinEnabled && kernelInput.IsSupportDualMine)
            {
                Guid dualCoinGroupId = coinKernel.DualCoinGroupId;
                if (dualCoinGroupId != Guid.Empty)
                {
                    if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out ICoin dualCoin))
                    {
                        ICoinProfile dualCoinProfile = this.MinerProfile.GetCoinProfile(dualCoin.GetId());
                        if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out IPool dualCoinPool))
                        {
                            IPoolProfile dualPoolProfile = MinerProfile.GetPoolProfile(dualCoinPool.GetId());
                            string       dualPassword    = dualPoolProfile.Password;
                            if (string.IsNullOrEmpty(dualPassword))
                            {
                                dualPassword = Consts.PasswordDefaultValue;
                            }
                            parameters.Add(Consts.DualCoinParameterName, dualCoin.Code);
                            parameters.Add(Consts.DualWalletParameterName, dualCoinProfile.DualCoinWallet);
                            parameters.Add(Consts.DualUserNameParameterName, dualPoolProfile.UserName);
                            parameters.Add(Consts.DualPasswordParameterName, dualPassword);
                            parameters.Add(Consts.DualHostParameterName, dualCoinPool.GetHost());
                            parameters.Add(Consts.DualPortParameterName, dualCoinPool.GetPort().ToString());
                            parameters.Add(Consts.DualPoolParameterName, dualCoinPool.Server);

                            kernelArgs = coinKernel.DualFullArgs;
                            AssembleArgs(parameters, ref kernelArgs, isDual: true);
                            AssembleArgs(parameters, ref poolKernelArgs, isDual: true);
                            AssembleArgs(parameters, ref customArgs, isDual: true);

                            string dualWeightArg;
                            if (!string.IsNullOrEmpty(kernelInput.DualWeightArg))
                            {
                                if (coinKernelProfile.IsAutoDualWeight && kernelInput.IsAutoDualWeight)
                                {
                                    dualWeightArg = string.Empty;
                                }
                                else
                                {
                                    dualWeightArg = $"{kernelInput.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}";
                                }
                            }
                            else
                            {
                                dualWeightArg = string.Empty;
                            }
                            StringBuilder dualSb = new StringBuilder();
                            dualSb.Append(kernelArgs);
                            if (!string.IsNullOrEmpty(dualWeightArg))
                            {
                                dualSb.Append(" ").Append(dualWeightArg);
                            }
                            if (!string.IsNullOrEmpty(poolKernelArgs))
                            {
                                dualSb.Append(" ").Append(poolKernelArgs);
                            }
                            BuildFragments(coinKernel, parameters, out fileWriters, out fragments);
                            foreach (var fragment in fragments.Values)
                            {
                                dualSb.Append(" ").Append(fragment);
                            }
                            if (!string.IsNullOrEmpty(customArgs))
                            {
                                dualSb.Append(" ").Append(customArgs);
                            }
                            if (!string.IsNullOrEmpty(devicesArgs))
                            {
                                dualSb.Append(" ").Append(devicesArgs);
                            }

                            // 注意:这里退出
                            return(dualSb.ToString());
                        }
                    }
                }
            }
            AssembleArgs(parameters, ref kernelArgs, isDual: false);
            AssembleArgs(parameters, ref coinKernelArgs, isDual: false);
            AssembleArgs(parameters, ref poolKernelArgs, isDual: false);
            AssembleArgs(parameters, ref customArgs, isDual: false);
            StringBuilder sb = new StringBuilder();

            sb.Append(kernelArgs);
            if (!string.IsNullOrEmpty(coinKernelArgs))
            {
                sb.Append(" ").Append(coinKernelArgs);
            }
            if (!string.IsNullOrEmpty(poolKernelArgs))
            {
                sb.Append(" ").Append(poolKernelArgs);
            }
            if (!string.IsNullOrEmpty(devicesArgs))
            {
                sb.Append(" ").Append(devicesArgs);
            }
            BuildFragments(coinKernel, parameters, out fileWriters, out fragments);
            foreach (var fragment in fragments.Values)
            {
                sb.Append(" ").Append(fragment);
            }
            if (!string.IsNullOrEmpty(customArgs))
            {
                sb.Append(" ").Append(customArgs);
            }

            return(sb.ToString());
        }
        public string BuildAssembleArgs()
        {
            if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out ICoin mainCoin))
            {
                return(string.Empty);
            }
            ICoinProfile coinProfile = this.MinerProfile.GetCoinProfile(mainCoin.GetId());

            if (!PoolSet.TryGetPool(coinProfile.PoolId, out IPool mainCoinPool))
            {
                return(string.Empty);
            }
            if (!CoinKernelSet.TryGetCoinKernel(coinProfile.CoinKernelId, out ICoinKernel coinKernel))
            {
                return(string.Empty);
            }
            if (!KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel))
            {
                return(string.Empty);
            }
            if (!kernel.IsSupported(mainCoin))
            {
                return(string.Empty);
            }
            if (!KernelInputSet.TryGetKernelInput(kernel.KernelInputId, out IKernelInput kernelInput))
            {
                return(string.Empty);
            }
            ICoinKernelProfile coinKernelProfile = this.MinerProfile.GetCoinKernelProfile(coinProfile.CoinKernelId);
            string             wallet            = coinProfile.Wallet;
            string             pool           = mainCoinPool.Server;
            string             poolKernelArgs = string.Empty;
            IPoolKernel        poolKernel     = PoolKernelSet.FirstOrDefault(a => a.PoolId == mainCoinPool.GetId() && a.KernelId == kernel.GetId());

            if (poolKernel != null)
            {
                poolKernelArgs = poolKernel.Args;
            }
            IPoolProfile poolProfile = MinerProfile.GetPoolProfile(mainCoinPool.GetId());
            string       userName    = poolProfile.UserName;
            string       password    = poolProfile.Password;

            if (string.IsNullOrEmpty(password))
            {
                password = "******";
            }
            string kernelArgs     = kernelInput.Args;
            string coinKernelArgs = coinKernel.Args;
            string customArgs     = coinKernelProfile.CustomArgs;
            var    argsDic        = new Dictionary <string, string> {
                { "mainCoin", mainCoin.Code },
                { "wallet", wallet },
                { "userName", userName },
                { "password", password },
                { "host", mainCoinPool.GetHost() },
                { "port", mainCoinPool.GetPort().ToString() },
                { "pool", pool },
                { "worker", this.MinerProfile.MinerName }
            };// 这里不要考虑{logfile},{logfile}往后推迟

            if (coinKernelProfile.IsDualCoinEnabled && kernelInput.IsSupportDualMine)
            {
                Guid dualCoinGroupId = coinKernel.DualCoinGroupId;
                if (dualCoinGroupId == Guid.Empty)
                {
                    dualCoinGroupId = kernelInput.DualCoinGroupId;
                }
                if (dualCoinGroupId != Guid.Empty)
                {
                    if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out ICoin dualCoin))
                    {
                        ICoinProfile dualCoinProfile = this.MinerProfile.GetCoinProfile(dualCoin.GetId());
                        if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out IPool dualCoinPool))
                        {
                            string       dualWallet      = dualCoinProfile.DualCoinWallet;
                            string       dualPool        = dualCoinPool.Server;
                            IPoolProfile dualPoolProfile = MinerProfile.GetPoolProfile(dualCoinPool.GetId());
                            string       dualUserName    = dualPoolProfile.UserName;
                            string       dualPassword    = dualPoolProfile.Password;
                            if (string.IsNullOrEmpty(dualPassword))
                            {
                                dualPassword = "******";
                            }
                            argsDic.Add("dualCoin", dualCoin.Code);
                            argsDic.Add("dualAlgo", dualCoin.Algo);
                            argsDic.Add("dualWallet", dualWallet);
                            argsDic.Add("dualUserName", dualUserName);
                            argsDic.Add("dualPassword", dualPassword);
                            argsDic.Add("dualHost", dualCoinPool.GetHost());
                            argsDic.Add("dualPort", dualCoinPool.GetPort().ToString());
                            argsDic.Add("dualPool", dualPool);

                            kernelArgs = kernelInput.DualFullArgs;
                            AssembleArgs(argsDic, ref kernelArgs, isDual: true);
                            AssembleArgs(argsDic, ref poolKernelArgs, isDual: true);
                            AssembleArgs(argsDic, ref customArgs, isDual: true);

                            string dualWeightArg;
                            if (!string.IsNullOrEmpty(kernelInput.DualWeightArg))
                            {
                                if (coinKernelProfile.IsAutoDualWeight && kernelInput.IsAutoDualWeight)
                                {
                                    dualWeightArg = string.Empty;
                                }
                                else
                                {
                                    dualWeightArg = $"{kernelInput.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}";
                                }
                            }
                            else
                            {
                                dualWeightArg = string.Empty;
                            }

                            return($"{kernelArgs} {dualWeightArg} {poolKernelArgs} {customArgs}");
                        }
                    }
                }
            }
            AssembleArgs(argsDic, ref kernelArgs, isDual: false);
            AssembleArgs(argsDic, ref coinKernelArgs, isDual: false);
            AssembleArgs(argsDic, ref poolKernelArgs, isDual: false);
            AssembleArgs(argsDic, ref customArgs, isDual: false);
            string devicesArgs = string.Empty;

            if (!string.IsNullOrWhiteSpace(kernelInput.DevicesArg))
            {
                List <int> useDevices = GetUseDevices();
                if (useDevices.Count != 0 && useDevices.Count != GpuSet.Count)
                {
                    string separator = kernelInput.DevicesSeparator;
                    if (kernelInput.DevicesSeparator == "space")
                    {
                        separator = " ";
                    }
                    if (string.IsNullOrEmpty(separator))
                    {
                        List <string> gpuIndexes = new List <string>();
                        foreach (var index in useDevices)
                        {
                            int i = index;
                            if (kernelInput.DeviceBaseIndex != 0)
                            {
                                i = index + kernelInput.DeviceBaseIndex;
                            }
                            if (i > 9)
                            {
                                gpuIndexes.Add(gpuIndexChars[i - 10]);
                            }
                            else
                            {
                                gpuIndexes.Add(i.ToString());
                            }
                        }
                        devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, gpuIndexes)}";
                    }
                    else
                    {
                        devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, useDevices)}";
                    }
                }
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(kernelArgs);
            if (!string.IsNullOrEmpty(coinKernelArgs))
            {
                sb.Append(" ").Append(coinKernelArgs);
            }
            if (!string.IsNullOrEmpty(poolKernelArgs))
            {
                sb.Append(" ").Append(poolKernelArgs);
            }
            if (!string.IsNullOrEmpty(devicesArgs))
            {
                sb.Append(" ").Append(devicesArgs);
            }
            if (!string.IsNullOrEmpty(customArgs))
            {
                sb.Append(" ").Append(customArgs);
            }
            return(sb.ToString());
        }
示例#4
0
        public string BuildAssembleArgs()
        {
            ICoin mainCoin;

            if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out mainCoin))
            {
                return(string.Empty);
            }
            ICoinProfile coinProfile = this.CoinProfileSet.GetCoinProfile(mainCoin.GetId());
            IPool        mainCoinPool;

            if (!PoolSet.TryGetPool(coinProfile.PoolId, out mainCoinPool))
            {
                return(string.Empty);
            }
            ICoinKernel coinKernel;

            if (!CoinKernelSet.TryGetKernel(coinProfile.CoinKernelId, out coinKernel))
            {
                return(string.Empty);
            }
            IKernel kernel;

            if (!KernelSet.TryGetKernel(coinKernel.KernelId, out kernel))
            {
                return(string.Empty);
            }
            if (!kernel.IsSupported())
            {
                return(string.Empty);
            }
            IKernelInput kernelInput;

            if (!KernelInputSet.TryGetKernelInput(kernel.KernelInputId, out kernelInput))
            {
                return(string.Empty);
            }
            ICoinKernelProfile coinKernelProfile = this.CoinKernelProfileSet.GetCoinKernelProfile(coinProfile.CoinKernelId);
            string             wallet            = coinProfile.Wallet;
            string             pool           = mainCoinPool.Server;
            string             kernelArgs     = kernelInput.Args;
            string             coinKernelArgs = coinKernel.Args;
            string             customArgs     = coinKernelProfile.CustomArgs;
            var argsDic = new Dictionary <string, string> {
                { "mainCoin", mainCoin.Code },
                { "mainAlgo", mainCoin.Algo },
                { "wallet", wallet },
                { "host", mainCoinPool.GetHost() },
                { "port", mainCoinPool.GetPort().ToString() },
                { "pool", pool },
                { "worker", this.MinerProfile.MinerName }
            };// 这里不要考虑{logfile},{logfile}往后推迟

            if (coinKernelProfile.IsDualCoinEnabled)
            {
                Guid dualCoinGroupId = coinKernel.DualCoinGroupId;
                if (dualCoinGroupId == Guid.Empty)
                {
                    dualCoinGroupId = kernelInput.DualCoinGroupId;
                }
                if (dualCoinGroupId != Guid.Empty)
                {
                    ICoin dualCoin;
                    if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out dualCoin))
                    {
                        ICoinProfile dualCoinProfile = this.CoinProfileSet.GetCoinProfile(dualCoin.GetId());
                        IPool        dualCoinPool;
                        if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out dualCoinPool))
                        {
                            string dualWallet = dualCoinProfile.DualCoinWallet;
                            string dualPool   = dualCoinPool.Server;
                            argsDic.Add("dualCoin", dualCoin.Code);
                            argsDic.Add("dualAlgo", dualCoin.Algo);
                            argsDic.Add("dualWallet", dualWallet);
                            argsDic.Add("dualHost", dualCoinPool.GetHost());
                            argsDic.Add("dualPort", dualCoinPool.GetPort().ToString());
                            argsDic.Add("dualPool", dualPool);

                            kernelArgs = kernelInput.DualFullArgs;
                            AssembleArgs(argsDic, ref kernelArgs, isDual: true);
                            AssembleArgs(argsDic, ref customArgs, isDual: true);

                            string dualWeightArg;
                            if (!string.IsNullOrEmpty(kernelInput.DualWeightArg))
                            {
                                if (coinKernelProfile.IsAutoDualWeight && kernelInput.IsAutoDualWeight)
                                {
                                    dualWeightArg = string.Empty;
                                }
                                else
                                {
                                    dualWeightArg = $"{kernelInput.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}";
                                }
                            }
                            else
                            {
                                dualWeightArg = string.Empty;
                            }

                            return($"{kernelArgs} {dualWeightArg} {customArgs}");
                        }
                    }
                }
            }
            AssembleArgs(argsDic, ref kernelArgs, isDual: false);
            AssembleArgs(argsDic, ref coinKernelArgs, isDual: false);
            AssembleArgs(argsDic, ref customArgs, isDual: false);

            return($"{kernelArgs} {coinKernelArgs} {customArgs}");
        }