Exemple #1
0
 /// <summary>
 /// Free up our resources.
 /// </summary>
 public void Dispose()
 {
     if (_miningInfoUpdater != null)
     {
         _miningInfoUpdater.PropertyChanged -= OnMiningInfoUpdate;
         _miningInfoUpdater.Dispose();
         _miningInfoUpdater = null;
     }
     if (_plotReaderManager != null)
     {
         _plotReaderManager.ScoopsDiscovered -= PlotReaderManagerOnScoopsDiscovered;
         _plotReaderManager.Dispose();
         _plotReaderManager = null;
     }
     if (_deadlineCalculator != null)
     {
         _deadlineCalculator.DeadlineFound -= DeadlineCalculatorOnDeadlineFound;
         _deadlineCalculator?.Dispose();
     }
     if (_consoleUi != null)
     {
         _consoleUi.Dispose();
     }
     Logger.Debug("Miner disposed");
 }
Exemple #2
0
        /// <summary>
        /// Start the miner.
        /// </summary>
        public void Run()
        {
            // Ensure we can only run once
            if (_started)
            {
                throw new Exception("Already started");
            }
            _started = true;

            // Start the UI
            _consoleUi = new ConsoleUi();
            Logger.Info("Miner starting up");

            // Create our plot reader manager to manage reading from disk
            Logger.Debug("Plot reader manager: starting");
            _plotReaderManager = new PlotReaderManager();
            _plotReaderManager.ScoopsDiscovered       += PlotReaderManagerOnScoopsDiscovered;
            _plotReaderManager.UtilisedStorageUpdated += PlotReaderManagerOnUtilisedStorageUpdated;
            Logger.Debug("Plot reader manager: started");

            // Create our deadline calculator and hook up to its events
            Logger.Debug("Deadline calculator: starting");
            _deadlineCalculator = new DeadlineCalculator(Configuration.MemoryLimitPlotChecker / Plot.SCOOP_SIZE, Configuration.ThreadCountPlotChecker);
            _deadlineCalculator.DeadlineFound += DeadlineCalculatorOnDeadlineFound;
            Logger.Debug("Deadline calculator: started");

            // Setup our deadline submitter
            Logger.Debug("Deadline submitter: starting");
            _deadlineSubmitter = new DeadlineSubmitter();
            _deadlineSubmitter.UpdateUtilisedStorage(_plotReaderManager.UtilisedStorage);
            Logger.Debug("Deadline submitter: started");

            // Create our mining info updater to listen for new rounds
            Logger.Debug("Mining info updater: starting");
            _miningInfoUpdater = new MiningInfoUpdater();
            _miningInfoUpdater.PropertyChanged += OnMiningInfoUpdate;
            Logger.Debug("Mining info updater: started");

            // Finally hand over to the console UI which blocks us
            Logger.Info("Miner has started up successfully");
            _consoleUi.Run();
        }