public static void GetCurrentBlock(string worker) { var ret = NiceHashStats.GetNiceHashApiData("https://etherchain.org/api/blocks/count", worker); if (ret == null) { Helpers.ConsolePrint(worker, $"Failed to obtain current block, using default {ConfigManager.GeneralConfig.ethminerDefaultBlockHeight}."); CurrentBlockNum = ConfigManager.GeneralConfig.ethminerDefaultBlockHeight.ToString(); } else { ret = ret.Substring(ret.LastIndexOf("count") + 7); CurrentBlockNum = ret.Substring(0, ret.Length - 3); } }
public static void UpdateApi(string worker) { var resp = NiceHashStats.GetNiceHashApiData(ApiUrl, worker); if (resp != null) { try { var lastResponse = JsonConvert.DeserializeObject <ExchangeRateJson>(resp, Globals.JsonSettings); // set that we have a response if (lastResponse != null) { var lastResult = lastResponse.result; _exchangesFiat = lastResult.exchanges_fiat; if (_exchangesFiat == null) { Helpers.ConsolePrint("CurrencyConverter", "Unable to retrieve update, Falling back to USD"); ActiveDisplayCurrency = "USD"; } else { ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency; } // ActiveDisplayCurrency = "USD"; // check if currency avaliable and fill currency list foreach (var pair in lastResult.exchanges) { if (pair.ContainsKey("USD") && pair.ContainsKey("coin") && pair["coin"] == "BTC" && pair["USD"] != null) { _usdBtcRate = Helpers.ParseDouble(pair["USD"]); break; } } } } catch (Exception e) { Helpers.ConsolePrint("ExchangeRateAPI", "UpdateAPI got Exception: " + e.Message); } } else { Helpers.ConsolePrint("ExchangeRateAPI", "UpdateAPI got NULL"); } }