Beispiel #1
0
        internal static MinerAccount Init()
        {
            // Attempt to read the GUID from the config file
            AccountIdentityFile accountIdentityFile = new AccountIdentityFile();
            var accountIdentity = accountIdentityFile.ReadJsonFromFile();

            var accountId = accountIdentity.AccountGuid;

            // Validate if a GUID was actually read
            if (accountId == Guid.Empty)
            {
                throw new Exception("Account Identity could not be found - you need to configure this node with an account id.");
            }


            AccountWalletAPI   accountWalletAPI   = new AccountWalletAPI();
            GPUSettingsAPI     gpuSettingsAPI     = new GPUSettingsAPI();
            WorkerSettingsFile workerSettingsFile = new WorkerSettingsFile();
            var workerSettings = workerSettingsFile.ReadJsonFromFile();

            return(new MinerAccount()
            {
                AccountId = accountId.ToString(),
                AccountWalletList = accountWalletAPI.GetAccountWalletList(accountId.ToString()),
                WorkerSettings = workerSettings,
                GPUSettingsList = gpuSettingsAPI.GetGPUSettings(accountId.ToString(), workerSettings.WorkerName)
            });
        }
 /// <summary>
 /// Get previously saved hardware GPU settings from API
 /// </summary>
 private void ReadWorkerHardwareFromAPI()
 {
     try
     {
         // Write GPU Settings to API
         GPUSettingsAPI gpuSettingsAPI = new GPUSettingsAPI();
         GPUSettingsList = gpuSettingsAPI.GetGPUSettings();
     }
     catch (Exception e)
     {
         throw new ApplicationException(string.Format("Error saving worker hardware settings"), e);
     }
 }
 /// <summary>
 /// Get previously saved hardware GPU settings from API
 /// </summary>
 private void ReadWorkerHardwareFromAPI()
 {
     try
     {
         // Write GPU Settings to API
         GPUSettingsAPI gpuSettingsAPI = new GPUSettingsAPI();
         var            accountId      = Application.Current.Properties["AccountID"].ToString();
         var            workerName     = Application.Current.Properties["WorkerName"].ToString();
         GPUSettingsList = gpuSettingsAPI.GetGPUSettings(accountId, workerName);
     }
     catch (Exception e)
     {
         throw new ApplicationException(string.Format("Error saving worker hardware settings"), e);
     }
 }
        /// <summary>
        /// Write GPU Settings to API
        /// </summary>
        /// <param name="param"></param>
        private void PersistWorkerHardware(object param)
        {
            try
            {
                // Write GPU Settings to API
                GPUSettingsAPI gpuSettingsAPI = new GPUSettingsAPI();
                gpuSettingsAPI.PostGPUSettings(GPUSettingsList);

                // Insert new worker for account if it doesnt already exist
                InsertAccountWorkers();

                // Set global variable for Worker Name
                Application.Current.Properties["GPUSettingsList"] = GPUSettingsList;

                // Notify success
                ShowSuccess(string.Format("Hardware changes saved successfully"));
            }
            catch (Exception e)
            {
                throw new ApplicationException(string.Format("Error saving worker hardware settings"), e);
            }
        }