Beispiel #1
0
        private void HandleProcessOutput(object sender, DataReceivedEventArgs e)
        {
            if (String.IsNullOrEmpty(e.Data))
            {
                return;
            }

            errorHandledByEvent = false;

            if ((e.Data.IndexOf("auth failed", StringComparison.OrdinalIgnoreCase) >= 0) && (AuthenticationFailed != null))
            {
                errorHandledByEvent = true; //must be done first as its async
                AuthenticationFailedArgs args = new AuthenticationFailedArgs();
                Match  match     = Regex.Match(e.Data, @" pool (\d) ");
                string poolIndex = "??";
                if (match.Success)
                {
                    poolIndex = match.Groups[1].Value;
                }
                args.Reason = String.Format("Authentication failed ({0} pool {1})",
                                            minerConfiguration.CoinName, poolIndex);
                AuthenticationFailed(this, args);
            }

            if (((e.Data.IndexOf("No servers could be used", StringComparison.OrdinalIgnoreCase) >= 0) ||
                 (e.Data.IndexOf("No servers were found", StringComparison.OrdinalIgnoreCase) >= 0)) &&
                (LaunchFailed != null))
            {
                errorHandledByEvent = true; //must be done first as its async
                LaunchFailedArgs args = new LaunchFailedArgs();
                args.Reason = String.Format("None of the pools configured for {0} could be used. Verify your pool settings and try again.",
                                            minerConfiguration.CoinName);
                args.CoinName = minerConfiguration.CoinName;
                LaunchFailed(this, args);
            }

            if (e.Data.IndexOf("detected new block", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                ((Process)sender).CancelOutputRead();
                ((Process)sender).CancelErrorRead();
            }
        }
Beispiel #2
0
        private void HandleProcessOutput(object sender, DataReceivedEventArgs e)
        {
            if (String.IsNullOrEmpty(e.Data))
            {
                return;
            }

            if (e.Data.Contains("auth failed") && (LaunchFailed != null))
            {
                LaunchFailedArgs args = new LaunchFailedArgs();
                args.Reason = "Authentication failed for your pool. Verify your pool settings and try again.";
                LaunchFailed(this, args);
            }

            if (e.Data.Contains("detected new block"))
            {
                ((Process)sender).CancelOutputRead();
                ((Process)sender).CancelErrorRead();
            }
        }
Beispiel #3
0
        private void HandleProcessOutput(object sender, DataReceivedEventArgs e)
        {
            if (String.IsNullOrEmpty(e.Data))
                return;

            errorHandledByEvent = false;

            if ((e.Data.IndexOf("auth failed", StringComparison.OrdinalIgnoreCase) >= 0) && (AuthenticationFailed != null))
            {
                errorHandledByEvent = true; //must be done first as its async
                AuthenticationFailedArgs args = new AuthenticationFailedArgs();
                Match match = Regex.Match(e.Data, @" pool (\d) ");
                string poolIndex = "??";
                if (match.Success)
                    poolIndex = match.Groups[1].Value;
                args.Reason = String.Format("Authentication failed ({0} pool {1})",
                    minerConfiguration.CoinName, poolIndex);
                AuthenticationFailed(this, args);
            }

            if (((e.Data.IndexOf("No servers could be used", StringComparison.OrdinalIgnoreCase) >= 0) ||
                (e.Data.IndexOf("No servers were found", StringComparison.OrdinalIgnoreCase) >= 0))
                && (LaunchFailed != null))
            {
                errorHandledByEvent = true; //must be done first as its async
                LaunchFailedArgs args = new LaunchFailedArgs();
                args.Reason = String.Format("None of the pools configured for {0} could be used. Verify your pool settings and try again.",
                    minerConfiguration.CoinName);
                args.CoinName = minerConfiguration.CoinName;
                LaunchFailed(this, args);
            }

            if (e.Data.IndexOf("detected new block", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                ((Process)sender).CancelOutputRead();
                ((Process)sender).CancelErrorRead();
            }
        }
Beispiel #4
0
        private void ProcessLaunchFailed(object sender, LaunchFailedArgs ea)
        {
            this.BeginInvoke((Action)(() =>
            {
                if (engineConfiguration.StrategyConfiguration.AutomaticallyMineCoins)
                {
                    string notificationReason = String.Empty;

                    int enabledConfigurationCount = engineConfiguration.CoinConfigurations.Count(c => c.Enabled);

                    //only disable the configuration if there are others enabled - otherwise left idling
                    if (enabledConfigurationCount > 1)
                    {

                        //if auto mining is enabled, disable the coin configuration and display a notification
                        CoinConfiguration coinConfiguration = engineConfiguration.CoinConfigurations.SingleOrDefault(config => config.Coin.Name.Equals(ea.CoinName, StringComparison.OrdinalIgnoreCase));
                        coinConfiguration.Enabled = false;
                        engineConfiguration.SaveCoinConfigurations();

                        //if no enabled configurations, stop mining
                        int enabledConfigurations = engineConfiguration.CoinConfigurations.Count(config => config.Enabled);
                        if (enabledConfigurations == 0)
                            StopMining();
                        else
                            //if there are enabled configurations, apply mining strategy
                            CheckAndApplyMiningStrategy();

                        notificationReason = String.Format("Configuration for {0} disabled - all pools down", ea.CoinName);
                    }
                    else
                    {
                        //otherwise just notify - relaunching option will take care of the rest
                        notificationReason = String.Format("All pools for {0} configuration are down", ea.CoinName);
                    }

                    notificationsControl.AddNotification(notificationReason, notificationReason, () =>
                    {
                        ConfigureCoins();
                    }, "");
                }
                else
                {
                    if (!applicationConfiguration.RestartCrashedMiners)
                    {
                        //if we are not restarting miners, display a dialog
                        MessageBox.Show(ea.Reason, "Launching Miner Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        //just notify - relaunching option will take care of the rest
                        string notificationReason = String.Format("All pools for {0} configuration are down", ea.CoinName);
                        notificationsControl.AddNotification(notificationReason, notificationReason, () =>
                        {
                            ConfigureCoins();
                        }, "");
                    }
                }
            }));
        }
        private void ProcessLaunchFailed(object sender, LaunchFailedArgs ea)
        {
            Context.BeginInvoke((Action)(() =>
            {
                if (EngineConfiguration.StrategyConfiguration.AutomaticallyMineCoins)
                {
                    string notificationReason;

                    int enabledConfigurationCount = EngineConfiguration.CoinConfigurations.Count(c => c.Enabled);

                    //only disable the configuration if there are others enabled - otherwise left idling
                    if (enabledConfigurationCount > 1)
                    {
                        //if auto mining is enabled, flag pools down in the coin configuration and display a notification
                        Coin coinConfiguration = EngineConfiguration.CoinConfigurations.SingleOrDefault(config => config.PoolGroup.Name.Equals(ea.CoinName, StringComparison.OrdinalIgnoreCase));
                        if (coinConfiguration != null) coinConfiguration.PoolsDown = true;

                        EngineConfiguration.SaveCoinConfigurations();

                        //if no enabled configurations, stop mining
                        int enabledConfigurations = EngineConfiguration.CoinConfigurations.Count(config => config.Enabled && !config.PoolsDown);
                        if (enabledConfigurations == 0)
                            StopMiningLocally();
                        else
                            //if there are enabled configurations, apply mining strategy
                            CheckAndApplyMiningStrategy();

                        notificationReason = String.Format("Configuration for {0} disabled - all pools down", ea.CoinName);
                    }
                    else
                    {
                        //otherwise just notify - relaunching option will take care of the rest
                        notificationReason = String.Format("All pools for {0} configuration are down", ea.CoinName);
                    }

                    PostNotification(notificationReason, ConfigurePoolsLocally, NotificationKind.Danger);
                }
                else
                {
                    if (!ApplicationConfiguration.RestartCrashedMiners)
                    {
                        //if we are not restarting miners, display a dialog
                        MessageBoxShow(ea.Reason, "Launching Miner Failed", PromptButtons.OK, PromptIcon.Error);
                    }
                    else
                    {
                        //just notify - relaunching option will take care of the rest
                        PostNotification(String.Format("All pools for {0} configuration are down", ea.CoinName), 
                            ConfigurePoolsLocally, NotificationKind.Danger);
                    }
                }
            }), null);
        }
Beispiel #6
0
        private void HandleProcessOutput(object sender, DataReceivedEventArgs e)
        {
            if (String.IsNullOrEmpty(e.Data))
                return;

            if (e.Data.Contains("auth failed") && (LaunchFailed != null))
            {
                LaunchFailedArgs args = new LaunchFailedArgs();
                args.Reason = "Authentication failed for your pool. Verify your pool settings and try again.";
                LaunchFailed(this, args);
            }

            if (e.Data.Contains("detected new block"))
            {
                ((Process)sender).CancelOutputRead();
                ((Process)sender).CancelErrorRead();
            }
        }
Beispiel #7
0
 private void ProcessLaunchFailed(object sender, LaunchFailedArgs ea)
 {
     this.BeginInvoke((Action)(() =>
     {
         //code to update UI
         StopMining();
         MessageBox.Show(ea.Reason, "Launching Miner Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }));
 }