Exemplo n.º 1
0
        public static string SetConnection(Connection connection)
        {
            try
            {
                //change connection M1 from API
                Logger.Log(LogLevel.INFO, "Setting new StratumConnection from API as Primary connection.");
                Logger.Log(LogLevel.INFO, "This will change connection in running instance of GGM miner.");
                Logger.Log(LogLevel.INFO, "To save connection permanently to config, use /api/config [POST]");
                Logger.Log(LogLevel.INFO, "Closing current Primary connection...");
                con_m1.StratumClose();
                if (con_m2?.IsConnected == true)
                {
                    con_m2.StratumClose();
                }

                Task.Delay(4000).Wait();
                Logger.Log(LogLevel.INFO, $"setting Primary to {connection.Login} :: {connection.ConnectionAddress}:{connection.ConnectionPort}");
                con_m1         = new StratumConnet(connection.ConnectionAddress, connection.ConnectionPort, 1, connection.Login, connection.Password, connection.Ssl);
                stopConnecting = false;           //bug fix for special situation when primary connection is down, and pushing new connection via API is in situation that stopConnecting =true and both m1 and m2 are IsConnecte==false.. then it was hanging without possibility to connect
                ConnectMain(chooseRandom: false); //primary first
                return("ok");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
 public static void CloseAll()
 {
     con_m1.StratumClose();
     con_m2.StratumClose();
     con_mf1.StratumClose();
     con_mf2.StratumClose();
     con_gf1.StratumClose();
     con_gf2.StratumClose();
 }
        public static void TryPrimary()
        {
            if (con_m1?.IsConnected == false)
            {
                if (con_m2?.IsConnected == true)
                {
                    con_m1.Connect();
                    if (con_m1?.IsConnected == true)
                    {
                        con_m1.ReconnectAction = ReconnectMain;
                        con_m1.SendLogin();

                        curr_m = con_m1;
                        curr_m.RequestJob();

                        con_m2.StratumClose();
                    }
                }
            }
        }
 private static void tryCloseConn(StratumConnet conn)
 {
     try
     {
         Task.Run(() => Task.Delay(5000).ContinueWith(_ =>
         {
             try { conn.StratumClose(); } catch { }
         }
                                                      ));
     }
     catch { }
 }
        //main (user) connection is disconnected, pause workers (stop burning electricity), disconnect fees, wait for reconnection
        private static void PauseAllMining()
        {
            if (curr_mf?.IsConnected == true)
            {
                curr_mf.StratumClose();
            }

            if (curr_gf?.IsConnected == true)
            {
                curr_gf.StratumClose();
            }

            Task.Delay(1000).Wait();

            WorkerManager.PauseAllWorkers();

            solutionCounter = 0;
        }