private void saveButton_Click(object sender, EventArgs e) { PoolGroup knownCoin = null; if (coinCombo.SelectedIndex >= 0) { knownCoin = filteredCoins[coinCombo.SelectedIndex]; } if (knownCoin == null) { PoolGroup newCoin = new PoolGroup(); newCoin.Name = coinCombo.Text; newCoin.Algorithm = GetSelectedAlgorithm().Name; using (CoinEditForm coinEditForm = new CoinEditForm(newCoin)) { if (coinEditForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SelectedCoin = newCoin; } else { DialogResult = System.Windows.Forms.DialogResult.Cancel; } } } else { SelectedCoin = knownCoin; } }
private void EditCurrentCoin(Coin currentConfiguration) { PoolGroup workingCoin = new PoolGroup(); ObjectCopier.CopyObject(currentConfiguration.PoolGroup, workingCoin); using (CoinEditForm coinEditForm = new CoinEditForm(workingCoin)) { DialogResult dialogResult = coinEditForm.ShowDialog(); if (dialogResult == DialogResult.OK) { Coin existingConfiguration = configurations.SingleOrDefault(c => (c != currentConfiguration) && c.PoolGroup.Id.Equals(workingCoin.Id, StringComparison.OrdinalIgnoreCase)); if (existingConfiguration == null) { ObjectCopier.CopyObject(workingCoin, currentConfiguration.PoolGroup); coinListBox.Items[coinListBox.SelectedIndex] = workingCoin.Name; } else { //don't create a dupe MessageBox.Show(String.Format("A configuration for {0} already exists.", workingCoin.Id), "Duplicate Configuration", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void SaveSettings() { if (string.IsNullOrEmpty(thresholdSymbolCombo.Text)) { this.strategyConfiguration.MinimumThresholdSymbol = string.Empty; } else { PoolGroup coin = knownCoins.SingleOrDefault(c => c.Name.Equals(thresholdSymbolCombo.Text)); if (coin != null) { this.strategyConfiguration.MinimumThresholdSymbol = coin.Id; } } if (singleCoinRadio.Checked) { strategyConfiguration.SwitchStrategy = Strategy.CoinSwitchStrategy.SingleMost; } else { strategyConfiguration.SwitchStrategy = Strategy.CoinSwitchStrategy.AllMost; } if (string.IsNullOrEmpty(thresholdValueEdit.Text)) { this.strategyConfiguration.MinimumThresholdValue = null; } else { double percentage; if (double.TryParse(thresholdValueEdit.Text, out percentage)) { strategyConfiguration.MinimumThresholdValue = percentage; } } if (multiCoinRadio.Checked) { if (string.IsNullOrEmpty(exceptionEdit.Text)) { this.strategyConfiguration.MineSingleMostOverrideValue = null; } else { double percentage; if (double.TryParse(exceptionEdit.Text, out percentage)) { strategyConfiguration.MineSingleMostOverrideValue = percentage; } } } strategyConfiguration.ProfitabilityKind = (Strategy.CoinProfitabilityKind)profitabilityKindCombo.SelectedIndex; strategyConfiguration.MiningBasis = (Strategy.CoinMiningBasis)miningBasisCombo.SelectedIndex; }
public void DestoryGroup() { StopAllCoroutines(); if (group != null) { group.Destroy(); group = null; } }
private Engine.Data.Configuration.Coin AddCoinConfiguration(PoolGroup poolGroup) { //don't allow two configurations for the same coin symbol Engine.Data.Configuration.Coin configuration = configurations.SingleOrDefault(c => c.PoolGroup.Id.Equals(poolGroup.Id, StringComparison.OrdinalIgnoreCase)); if (configuration == null) { //don't allow two configurations for the same coin name configuration = configurations.SingleOrDefault(c => c.PoolGroup.Name.Equals(poolGroup.Name, StringComparison.OrdinalIgnoreCase)); } if (configuration != null) { coinListBox.SelectedIndex = configurations.IndexOf(configuration); } else { configuration = new Engine.Data.Configuration.Coin(); configuration.PoolGroup = knownCoins.SingleOrDefault(c => c.Id.Equals(poolGroup.Id, StringComparison.OrdinalIgnoreCase)); //user may have manually entered a coin or may be using a Multipool if (configuration.PoolGroup == null) { configuration.PoolGroup = new PoolGroup(); ObjectCopier.CopyObject(poolGroup, configuration.PoolGroup); } //at this point, configuration.CryptoCoin.Algorithm MAY be the CoinAlgorithm.FullName //that is how data from Coin API is stored //but coin configurations are based on CoinAlgorithm.Name CoinAlgorithm algorithm = MinerFactory.Instance.Algorithms.SingleOrDefault(a => a.FullName.Equals(configuration.PoolGroup.Algorithm, StringComparison.OrdinalIgnoreCase)); if (algorithm != null) { configuration.PoolGroup.Algorithm = algorithm.Name; } MiningPool miningPool = new MiningPool() { Host = UX.Data.Configuration.PoolDefaults.HostPrefix, Port = UX.Data.Configuration.PoolDefaults.Port }; configuration.Pools.Add(miningPool); configurations.Add(configuration); coinListBox.Items.Add(configuration.PoolGroup.Name); coinListBox.SelectedIndex = configurations.IndexOf(configuration); } hostEdit.Focus(); hostEdit.SelectionStart = hostEdit.SelectionLength; return(configuration); }
private void saveButton_Click(object sender, EventArgs e) { PoolGroup result = new PoolGroup(); string multipoolAlgorithm = GetSelectedAlgorithm().Name; string multipoolApi = multipoolCombo.Text; result.Algorithm = multipoolAlgorithm; result.Name = multipoolApi + " - " + multipoolAlgorithm.ToSpaceDelimitedWords(); result.Id = multipoolApi + ":" + multipoolAlgorithm; result.Kind = PoolGroup.PoolGroupKind.MultiCoin; SelectedMultipool = result; }
public void Builder_Returns_Correct_Matches_for_Multiple_Rounds() { PoolGroupBuilder builder = new PoolGroupBuilder(); PoolGroup poolGroup = builder .WithPools(1) .WithTeams(4) .WithRounds(2) .UsingSeed(SeedMethod.Sequential); Assert.True(poolGroup.Pools[0].Games[0].Id == 0); Assert.True(poolGroup.Pools[0].Games[11].Id == 11); }
public void Builder_Returns_Two_Pools_with_Even_Num_of_Team() { PoolGroupBuilder builder = new PoolGroupBuilder(); PoolGroup poolGroup = builder .WithPools(2) .WithTeams(4) .UsingSeed(SeedMethod.Snake); var result = poolGroup.Pools.All(pool => pool.Teams.Count == 2); Assert.True(result); }
public void Builder_Returns_Pool_Group_of_Requested_Size() { PoolGroupBuilder builder = new PoolGroupBuilder(); var expected = 2; PoolGroup poolGroup = builder .WithPools(expected); var actual = poolGroup.Pools.Count(); Assert.Equal(expected, actual); }
public void Builder_Returns_Four_Pools_Distributes_Fourteen_Teams_Using_Seq_Seed() { PoolGroupBuilder builder = new PoolGroupBuilder(); PoolGroup poolGroup = builder .WithPools(4) .WithTeams(14) .UsingSeed(SeedMethod.Sequential); var IsFour = poolGroup.Pools.Take(2).All(pool => pool.Teams.Count == 4); var IsThree = poolGroup.Pools.TakeLast(2).All(pool => pool.Teams.Count == 3); Assert.True(IsFour && IsThree); }
public void Builder_Returns_Two_Pools_with_Odd_Num_of_Teams_seq() { PoolGroupBuilder builder = new PoolGroupBuilder(); PoolGroup poolGroup = builder .WithPools(2) .WithTeams(5) .UsingSeed(SeedMethod.Sequential); var IsThree = poolGroup.Pools[0].Teams.Count.Equals(3); var IsTwo = poolGroup.Pools[1].Teams.Count.Equals(2); Assert.True(IsTwo && IsThree); }
public void Builder_Returns_Single_Pool_With_Specified_Number_of_Teams() { PoolGroupBuilder builder = new PoolGroupBuilder(); var expected = 5; PoolGroup poolGroup = builder .WithPools(1) .WithTeams(expected) .UsingSeed(SeedMethod.Snake); var actual = poolGroup.Pools.First().Teams.Count; Assert.Equal(expected, actual); }
private void HandleGroup() { serializedObject.Update(); PoolGroup poolGroup = (PoolGroup)target; poolGroup.groupTag = EditorGUILayout.TextField("Group tag", poolGroup.groupTag); if (GUI.changed) { Undo.RecordObject(poolGroup, $"Pool group Modify"); EditorUtility.SetDirty(poolGroup); } serializedObject.ApplyModifiedProperties(); }
private Engine.Data.Configuration.Engine CreateEngineConfiguration() { Engine.Data.Configuration.Engine engineConfiguration = new Engine.Data.Configuration.Engine(); Engine.Data.Configuration.Coin coinConfiguration = new Engine.Data.Configuration.Coin(); PoolGroup coin = coins.SingleOrDefault(c => c.Name.Equals(coinComboBox.Text)); //no Internet connection (or coin API offline) - only BTC and LTC were available if (coin == null) { coin = new PoolGroup(); coin.Name = coinComboBox.Text; if (coin.Name.Equals(KnownCoins.LitecoinName, StringComparison.OrdinalIgnoreCase)) { coin.Algorithm = AlgorithmNames.Scrypt; coin.Id = KnownCoins.LitecoinSymbol; } else { coin.Algorithm = AlgorithmNames.SHA256; coin.Id = KnownCoins.BitcoinSymbol; } } else { coin = coins.Single(c => c.Name.Equals(coinComboBox.Text)); } coinConfiguration.PoolGroup = coin; coinConfiguration.Enabled = true; MiningPool miningPool = new MiningPool(); miningPool.Host = hostEdit.Text; miningPool.Port = Int32.Parse(portEdit.Text); miningPool.Username = usernameEdit.Text; miningPool.Password = passwordEdit.Text; coinConfiguration.Pools.Add(miningPool); engineConfiguration.CoinConfigurations.Add(coinConfiguration); return(engineConfiguration); }
public void Builder_Returns_Teams_Correctly_Named_for_Snake_Seed() { PoolGroupBuilder builder = new PoolGroupBuilder(); PoolGroup poolGroup = builder .WithPools(4) .WithTeams(14) .UsingSeed(SeedMethod.Snake); var isTeamFour = poolGroup.Pools[3].Teams[0].Name.Equals("Team 4"); var isTeamFive = poolGroup.Pools[3].Teams[1].Name.Equals("Team 5"); var isTeamTwelve = poolGroup.Pools[3].Teams[2].Name.Equals("Team 12"); var isTeamThirteen = poolGroup.Pools[3].Teams[3].Name.Equals("Team 13"); Assert.True(isTeamFour && isTeamFive && isTeamTwelve && isTeamThirteen); }
public void Builder_Returns_Pools_Correctly_Named() { PoolGroupBuilder builder = new PoolGroupBuilder(); PoolGroup poolGroup = builder .WithPools(4) .WithTeams(1) .UsingSeed(SeedMethod.Sequential); var IsPoolA = poolGroup.Pools[0].Name.Equals("Pool A"); var IsPoolB = poolGroup.Pools[1].Name.Equals("Pool B"); var IsPoolC = poolGroup.Pools[2].Name.Equals("Pool C"); var IsPoolD = poolGroup.Pools[3].Name.Equals("Pool D"); Assert.True(IsPoolA && IsPoolB && IsPoolC && IsPoolD); }
public void Builder_Returns_Teams_Correctly_Named_for_Seq_Seed() { PoolGroupBuilder builder = new PoolGroupBuilder(); PoolGroup poolGroup = builder .WithPools(4) .WithTeams(14) .UsingSeed(SeedMethod.Sequential); var isTeamTwo = poolGroup.Pools[1].Teams[0].Name.Equals("Team 2"); var isTeamSix = poolGroup.Pools[1].Teams[1].Name.Equals("Team 6"); var isTeamTen = poolGroup.Pools[1].Teams[2].Name.Equals("Team 10"); var isTeamFourteen = poolGroup.Pools[1].Teams[3].Name.Equals("Team 14"); Assert.True(isTeamTwo && isTeamSix && isTeamTen && isTeamFourteen); }
private void copyCoinButton_Click(object sender, EventArgs e) { CoinChooseForm coinChooseForm = new CoinChooseForm(knownCoins); DialogResult dialogResult = coinChooseForm.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { PoolGroup destinationCoin = coinChooseForm.SelectedCoin; Engine.Data.Configuration.Coin sourceConfiguration = configurations[coinListBox.SelectedIndex]; MultiMiner.Engine.Data.Configuration.Coin destinationConfiguration = AddCoinConfiguration(destinationCoin); ObjectCopier.CopyObject(sourceConfiguration, destinationConfiguration, "CryptoCoin"); BindToCurrentConfiguration(); coinConfigurationBindingSource.ResetBindings(false); miningPoolBindingSource.ResetBindings(false); } }
private void LoadSettings() { PoolGroup coin = knownCoins.SingleOrDefault(c => c.Id.Equals(this.strategyConfiguration.MinimumThresholdSymbol)); if (coin != null) { thresholdSymbolCombo.Text = coin.Name; } singleCoinRadio.Checked = strategyConfiguration.SwitchStrategy == Strategy.CoinSwitchStrategy.SingleMost; multiCoinRadio.Checked = strategyConfiguration.SwitchStrategy == Strategy.CoinSwitchStrategy.AllMost; thresholdValueEdit.Text = strategyConfiguration.MinimumThresholdValue.ToString(); if (multiCoinRadio.Checked) { exceptionEdit.Text = strategyConfiguration.MineSingleMostOverrideValue.ToString(); } profitabilityKindCombo.SelectedIndex = (int)strategyConfiguration.ProfitabilityKind; miningBasisCombo.SelectedIndex = (int)strategyConfiguration.MiningBasis; }
public CoinEditForm(PoolGroup cryptoCoin) { InitializeComponent(); this.cryptoCoin = cryptoCoin; }
public Coin() { Pools = new List <MiningPool>(); Enabled = true; PoolGroup = new PoolGroup(); }
public MultipoolChooseForm(PoolGroup currentMultipool) { InitializeComponent(); this.currentMultipool = currentMultipool; }
public Device() { Workers = new List <Device>(); Coin = new PoolGroup(); }
public IEnumerator TestCache() { group = PoolManager.groups.Create("WarPoolGroup"); pool.prefab = prefab; // 缓存池这个Prefab的预加载数量。意思为一开始加载的数量! pool.preloadAmount = 3; // 如果勾选表示缓存池所有的gameobject可以“异步”加载。 pool.preloadTime = true; // 每几帧加载一个。 pool.preloadFrames = 2; // 延迟多久开始加载。 pool.preloadDelay = 0; // 是否打印日志信息 pool.logMessages = false; group.CreatePool(pool); status = "Init"; yield return(new WaitForSeconds(1)); for (int i = 0; i < 20; i++) { Debug.LogFormat("-----Spawn {0}----", i); status = "Spawn "; for (int j = 0; j < 10; j++) { Transform item = group.Spawn(prefab); item.position = Vector3.forward * (j + 0.5f); list.Add(item); Debug.LogFormat("[Spawn] {0}, {1}", j, item); Debug.Log(pool); status = "Spawn " + j; current = item; yield return(new WaitForSeconds(0.2f)); } yield return(new WaitForSeconds(1)); Debug.Log("-----Despawn 1----"); for (int j = list.Count - 1; j >= 0; j--) { Transform item = list[j]; group.Despawn(item); Debug.Log(pool); status = "Despawn " + j; current = item; yield return(new WaitForSeconds(0.2f)); } list.Clear(); yield return(new WaitForSeconds(1)); } }
public Coin() { Pools = new List<MiningPool>(); Enabled = true; PoolGroup = new PoolGroup(); }
public static int UpdatePoolGroup(PoolGroup group) { return(SugarBase.DBAutoClose.Updateable(group).ExecuteCommand()); }