public void ConvertCoinSet() { //获取到XML的根元素进行操作 XElement root = Document.Root; var coinList = root.Elements("Coin"); foreach (var coin in coinList) { var coinInfo = new CoinInfo(); coinInfo.Convert = new List <string>(); //Id XElement Id = coin.Element("Id"); coinInfo.Id = Id.Value.ToString(); //Name XElement Name = coin.Element("Name"); coinInfo.Name = Name.Value.ToString(); //Tag XElement Tag = coin.Element("Tag"); coinInfo.Tag = Tag.Value.ToString(); //Convert XElement Convert = coin.Element("Convert"); var infoList = Convert.Elements("Info"); foreach (var info in infoList) { coinInfo.Convert.Add(info.Value.ToString()); } CoinSet.Add(coinInfo); } }
private static IEnumerable <CoinSet> Answers() { const int CoinSumMax = 15; for (int i = 0; i <= CoinSumMax; i++) { for (int j = 0; j <= CoinSumMax - i; j++) { for (int k = 0; k <= CoinSumMax - i - j; k++) { for (int l = 0; l <= CoinSumMax - i - j - k; l++) { var set = new CoinSet() { Coin500Number = i, Coin100Number = j, Coin50Number = k, Coin10Number = l }; if (set.SumYen == 1000) { yield return(set); } } } } } }
public void setData(CoinSet data) { this.data = data; this.button.Text = this.data.value.ToString(); this.label.Text = this.data.count.ToString(); this.Enabled = this.data.count > 0; }
private int GetScore(List <int> coins, int start, int end, Dictionary <CoinSet, int> scores) { if (start >= end) { return(0); } var coinSet = new CoinSet(start, end); if (scores.ContainsKey(coinSet)) { return(scores[coinSet]); } var take1 = coins[start]; var score11 = GetScore(coins, start + 2, end, scores); var score12 = GetScore(coins, start + 1, end - 1, scores); var score1Min = take1 + Math.Min(score11, score12); // the opponent is as smart as you :) var take2 = coins[end]; var score21 = GetScore(coins, start, end - 2, scores); var score22 = score12; var score2Min = take2 + Math.Min(score21, score22); var scoreMax = Math.Max(score1Min, score2Min); scores.Add(new CoinSet(start, end), scoreMax); return(scoreMax); }
public void StartPattern() { gameControl = GameObject.Find("GameControl").GetComponent("GameControl") as GameControl; gp = GameObject.Find("GameControl").GetComponent<GamePlay>(); gp.Bonus = false; transform.position = new Vector3(18, gp.lastFlowY, transform.position.z); gp.LastP = transform.gameObject; c = transform.FindChild("Coin").GetComponent("CoinSet") as CoinSet; c.TurnCoin(true); check = true; end = false; }
public void StartPattern() { if(gp == null) gp = GameObject.Find("GameControl").GetComponent<GamePlay>(); flowY = (int)Random.Range(-1.5F,1.5F); if(gp.lastFlowY > 0 && flowY > 0) flowY = 0; else if(gp.lastFlowY < 1 && flowY == -1) flowY = 0; gp.lastFlowY += flowY; transform.position = new Vector3(17.7F+gp.nextHop,gp.lastFlowY,transform.position.z); gp.nextHop = transform.position.x + ((size-1)*18); if(transform.FindChild("Coin") != null) { if(c == null) c = transform.FindChild("Coin").GetComponent("CoinSet") as CoinSet; c.TurnCoin(true); } gp.PatterOn = true; //check = true; //end = false; }
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()); }
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()); }
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() { 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); } ICoinKernelProfile coinKernelProfile = this.CoinKernelProfileSet.GetCoinKernelProfile(coinProfile.CoinKernelId); string wallet = coinProfile.Wallet; string pool = mainCoinPool.Server; string kernelArgs = kernel.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 = kernel.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 = kernel.DualFullArgs; AssembleArgs(argsDic, ref kernelArgs, isDual: true); AssembleArgs(argsDic, ref customArgs, isDual: true); string dualWeightArg; if (!string.IsNullOrEmpty(kernel.DualWeightArg)) { if (coinKernelProfile.IsAutoDualWeight && kernel.IsAutoDualWeight) { dualWeightArg = string.Empty; } else { dualWeightArg = $"{kernel.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}"); }
public void PutChangeBack(CoinSet coinSet) { _coinStash.Put(coinSet); }
public static CoinSetDTO FromCoinSet(CoinSet coinSet) => new CoinSetDTO { Denomination = coinSet.Denomination, Amount = coinSet.Amount };