예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
                    }
                }
            }
        }
예제 #3
0
        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;
        }
예제 #4
0
    public void DestoryGroup()
    {
        StopAllCoroutines();

        if (group != null)
        {
            group.Destroy();
            group = null;
        }
    }
예제 #5
0
        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);
        }
예제 #6
0
        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;
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
    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();
    }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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);
        }
예제 #18
0
        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);
            }
        }
예제 #19
0
        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;
        }
예제 #20
0
 public CoinEditForm(PoolGroup cryptoCoin)
 {
     InitializeComponent();
     this.cryptoCoin = cryptoCoin;
 }
예제 #21
0
 public Coin()
 {
     Pools     = new List <MiningPool>();
     Enabled   = true;
     PoolGroup = new PoolGroup();
 }
예제 #22
0
 public MultipoolChooseForm(PoolGroup currentMultipool)
 {
     InitializeComponent();
     this.currentMultipool = currentMultipool;
 }
예제 #23
0
 public Device()
 {
     Workers = new List <Device>();
     Coin    = new PoolGroup();
 }
예제 #24
0
    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));
        }
    }
예제 #25
0
 public Coin()
 {
     Pools = new List<MiningPool>();
     Enabled = true;
     PoolGroup = new PoolGroup();
 }
예제 #26
0
 public static int UpdatePoolGroup(PoolGroup group)
 {
     return(SugarBase.DBAutoClose.Updateable(group).ExecuteCommand());
 }