Example #1
0
        static void Main(string[] args)
        {
            System.Console.WriteLine(BANNER);

            Console.WriteLine($@"BPM home directory: {Core.GetBPMBaseUserDirectory()}");
            Console.WriteLine($@"BPM miners directory: {Core.GetBaseMinersDir()}");
            var minerAccount  = MinerAccount.Init();
            var miningSession = new MiningSession();

            miningSession.RemoveAllMiners();
            System.Console.WriteLine($@"Account Id: {minerAccount.AccountId}");
            System.Console.WriteLine($@"Region: {minerAccount.Region}");
            System.Console.WriteLine($@"Worker: {minerAccount.WorkerSettings.WorkerName}");
            System.Console.WriteLine(@"Configured Wallets:");
            minerAccount.AccountWalletList.Select(w => $@"  {w.CoinName}: {w.WalletAddress}")
            .ToList().ForEach(System.Console.WriteLine);

            // Call API and retrieve a list of miner configurations used to start mining
            List <MinerConfigResponse> minerConfigResponseList = GetMinerConfigurations(minerAccount);
            var hardwareMonitor = new LinuxHardwareMonitor();
            var minerFactory    = new MinerFactory(hardwareMonitor);

            // Iterate through returned responses from API and initialize miners
            foreach (MinerConfigResponse minerConfigResponse in minerConfigResponseList)
            {
                // Create miner session
                var miner = minerFactory.CreateMiner(minerConfigResponse.MinerBaseType, minerConfigResponse.HardwareType);
                miner.CoinType       = minerConfigResponse.CoinSelectedForMining;
                miner.MinerArguments = minerConfigResponse.MinerConfigString;
                miningSession.AddMiner(miner);
                System.Console.WriteLine(string.Format("Mining started {0} {1}", minerConfigResponse.MinerBaseType, minerConfigResponse.MinerConfigString));
            }

            System.Console.ReadLine();
        }
Example #2
0
        /// <summary>
        /// Call API and retrieve a list of miner configurations used to start mining
        /// </summary>
        /// <returns></returns>
        private static List <MinerConfigResponse> GetMinerConfigurations(MinerAccount minerAccount)
        {
            // Build api Request object
            MinerConfigRequest minerConfigRequest = new MinerConfigRequest();

            minerConfigRequest.Region            = minerAccount.Region;
            minerConfigRequest.AccountWalletList = minerAccount.AccountWalletList;
            minerConfigRequest.GPUSettingsList   = minerAccount.GPUSettingsList.ToList();

            // Call the web API the get a response with a list of miner config strings used
            // to start one or more mining sessions based on the current miners configurations
            MinerConfigStringAPI       minerConfigStringAPI    = new MinerConfigStringAPI();
            List <MinerConfigResponse> minerConfigResponseList = minerConfigStringAPI.GetMinerConfigResponses(minerConfigRequest);

            return(minerConfigResponseList);
        }