private static string FixAlgorithmName(string algorithm) { string result = algorithm; if (algorithm.Equals(ApiContext.ScryptNFactor, StringComparison.OrdinalIgnoreCase)) { result = AlgorithmFullNames.ScryptN; } else { KnownAlgorithm knownAlgorithm = KnownAlgorithms.Algorithms.SingleOrDefault(a => a.Name.Equals(algorithm, StringComparison.OrdinalIgnoreCase)); if (knownAlgorithm != null) { result = knownAlgorithm.FullName; } } return(result); }
public IEnumerable <MultipoolInformation> GetMultipoolInformation(string userAgent = "") { WebClient client = new ApiWebClient(); if (!string.IsNullOrEmpty(userAgent)) { client.Headers.Add("user-agent", userAgent); } string apiUrl = GetApiUrl(); string jsonString = client.DownloadString(apiUrl); JObject jsonObject = JObject.Parse(jsonString); jsonObject = jsonObject.Value <JObject>("result"); JArray jsonArray = jsonObject.Value <JArray>("stats"); List <MultipoolInformation> result = new List <MultipoolInformation>(); foreach (JToken jToken in jsonArray) { MultipoolInformation multipoolInformation = new MultipoolInformation(); if (multipoolInformation.PopulateFromJson(jToken)) { result.Add(multipoolInformation); } } MultipoolInformation btcInformation = result.Single(mpi => mpi.Algorithm.Equals(AlgorithmNames.SHA256)); foreach (MultipoolInformation otherInformation in result) { KnownAlgorithm knownAlgorithm = KnownAlgorithms.Algorithms.Single(ka => ka.Name.Equals(otherInformation.Algorithm)); otherInformation.Profitability = ((otherInformation.Price * knownAlgorithm.Multiplier) / btcInformation.Price) * PoolProfitability * 100; } return(result); }