예제 #1
0
파일: Form1.cs 프로젝트: Gerz-inc/mminer
        private void refresh_workers(bool allow_change_coin = true)
        {
            enabled_workers.Clear();
            currnet_sort.Clear();
            db.select(qry, new db_sqlite.dell((System.Data.Common.DbDataRecord record) =>
            {
                work_item_struct item = new work_item_struct();

                item.id                   = base_func.ParseInt32(record["id"]);
                item.statistic            = record["statistic"].ToString();
                item.miner                = record["miner"].ToString();
                item.manual_diff          = base_func.ParseDouble(record["manual_diff"]);
                item.pool_name            = record["pool_name"].ToString();
                item.url                  = record["url"].ToString();
                item.pass                 = record["pass"].ToString();
                item.connection_type_name = record["connection_type_name"].ToString();
                item.algo_name            = record["algo_name"].ToString();
                item.wallet_name          = record["wallet_name"].ToString();
                item.coin                 = record["coin"].ToString();
                item.exchange_name        = record["exchange_name"].ToString();
                item.min_running          = base_func.ParseInt32(record["min_running"]);

                enabled_workers.Add(item.id, item);

                return(true);
            }));

            sort_workers(allow_change_coin);
        }
예제 #2
0
파일: Form1.cs 프로젝트: Gerz-inc/mminer
        private void timer3_Tick(object sender, EventArgs e)
        {
            if (autostart_flag)
            {
                if (!is_running.Value && !is_miner_running.Value)
                {
                    autostart_flag = false;
                    run_miner();
                }
            }

            //read pipe
            string msg = pipe.pull_message();

            if (msg != "")
            {
                string[] exp = baseFunc.base_func.explode("|", msg);
                if (exp.Length >= 2)
                {
                    int    id_run = base_func.ParseInt32(exp[0]);
                    string what   = exp[1];

                    richTextBox2.AppendText("\n[pipe] ", Color.BurlyWood);
                    richTextBox2.AppendText(what);

                    /*if (line.Contains("is not supported")) pipe.write("" + current_id_running.ToString() + "|not_supported");
                     * else if (line.Contains("connection interrupted")) pipe.write("" + current_id_running.ToString() + "|connection interrupted");
                     * else if (line.Contains("Failed to connect")) pipe.write("" + current_id_running.ToString() + "|Failed to connect");
                     * else if (line.Contains("waiting for data")) pipe.write("" + current_id_running.ToString() + "|waiting for data");
                     * else if (line.Contains("Could not resolve host")) pipe.write("" + current_id_running.ToString() + "|Could not resolve host");*/

                    if (enabled_workers.ContainsKey(id_run))
                    {
                        work_item_struct worker = enabled_workers[id_run];

                        if (what == "not_supported")
                        {
                            worker.stopped_msg = what;
                            worker.cant_run    = true;
                            refresh_workers_display();
                        }
                        else if (what == "connection interrupted" || what == "Failed to connect")
                        {
                            int cnt = worker.get_count_pipe_msg(what);
                            if (cnt >= 1)
                            {
                                worker.stopped_msg    = what;
                                worker.stopped_before = DateTime.Now.AddMinutes(60);
                                refresh_workers_display();
                            }
                            else
                            {
                                worker.add_pipe_msg(what);
                            }
                        }
                        else if (what == "Could not resolve host")
                        {
                            worker.stopped_msg    = what;
                            worker.stopped_before = DateTime.Now.AddMinutes(60);
                            refresh_workers_display();
                        }
                        else if (what == "waiting for data")
                        {
                            int cnt = worker.get_count_pipe_msg(what);
                            if (cnt > 30)
                            {
                                worker.stopped_msg    = what;
                                worker.stopped_before = DateTime.Now.AddMinutes(60);
                                refresh_workers_display();
                            }
                            else
                            {
                                worker.add_pipe_msg(what);
                            }
                        }
                    }
                }
            }

            //date time
            DateTime dt = DateTime.Now;

            if (curr_date.Date != dt.Date)
            {
                curr_date = dt;

                //clear
                db.update_or_insert("delete from times where dat < '" + curr_date.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'; ");

                refresh_workers_display();
            }

            sort_workers();
        }
예제 #3
0
파일: Form1.cs 프로젝트: Gerz-inc/mminer
        private void sort_workers(bool allow_change_coin = true, bool skip_check = false)
        {
            //unfreeze
            DateTime dt_now = DateTime.Now;

            foreach (var itt in enabled_workers)
            {
                if (itt.Value.stopped_before != DateTime.MinValue)
                {
                    if (itt.Value.stopped_before < dt_now)
                    {
                        itt.Value.stopped_before = DateTime.MinValue;
                    }
                }
            }

            var lnq = from it in enabled_workers
                      orderby it.Value.cant_run, it.Value.stopped_before, it.Value.get_diff()
            select it;

            List <int> s = new List <int>();

            foreach (var itt in lnq)
            {
                s.Add(itt.Key);
            }

            if (!s.SequenceEqual(currnet_sort))
            {
                //check threshold delta and min_running time
                if (allow_change_coin && !skip_check)
                {
                    double   current_d     = 0;
                    double   f_d           = 0;
                    int      test_next_id  = 0;
                    int      min_running   = 0;
                    DateTime start_running = DateTime.MinValue;
                    bool     check_ok      = true;
                    for (int i = 0; i < currnet_sort.Count; ++i)
                    {
                        int id = currnet_sort[i];
                        work_item_struct it = enabled_workers[id];
                        if (i == 0)
                        {
                            f_d          = it.get_diff();
                            test_next_id = id;
                        }
                        if (id == current_id_running)
                        {
                            current_d     = it.get_diff();
                            min_running   = it.min_running;
                            start_running = it.start_running;

                            if (it.cant_run || it.stopped_before != DateTime.MinValue)
                            {
                                check_ok = false;
                            }
                        }
                    }
                    if (check_ok)
                    {
                        if (test_next_id != current_id_running)
                        {
                            if (current_d - f_d < threshold_switch_delta)
                            {
                                refresh_workers_display();
                                return;
                            }
                        }
                        if (min_running != 0 && (int)((DateTime.Now - start_running).TotalMinutes) < min_running)
                        {
                            refresh_workers_display();
                            return;
                        }
                    }
                }

                bool change_coin = false;

                currnet_sort = s;
                panel1.Controls.Clear();
                for (int i = 0; i < currnet_sort.Count; ++i)
                {
                    int id = currnet_sort[i];

                    work_item_struct it = enabled_workers[id];

                    if (i == 0)
                    {
                        it.is_running = true;
                        if (it.id != current_id_running)
                        {
                            change_coin        = true;
                            current_id_running = it.id;
                        }
                    }
                    else
                    {
                        it.is_running = false;
                    }

                    work_item item = new work_item();
                    item.init(ref it);
                    item.Left = 3;
                    item.Top  = (panel1.Controls.Count * (item.Height + 3)) + 3;
                    panel1.Controls.Add(item);
                }

                if (change_coin && allow_change_coin)
                {
                    refresh_workers_display();

                    richTextBox2.AppendText("\n[strategy] ", Color.Green);
                    richTextBox2.AppendText("Changing coin");
                    is_running.Value = false;
                    autostart_flag   = true;
                }
            }
        }
예제 #4
0
 public void init(ref work_item_struct data_)
 {
     data = data_;
     refresh();
 }