public Embed Build(MiningPoolStatsData data, IMessage message) { EmbedBuilder builder = this.CreateDefaultEmbed(message); builder.WithFooter("Data provided by PoolMiningStats", this._options.CoinIconURL); builder.WithTimestamp(data.Timestamp); StringBuilder poolListBuilder = new StringBuilder(); int i = 0; foreach (MiningPoolStatsData.PoolData pool in data.Pools.OrderByDescending(p => p.Hashrate).Take(10)) { poolListBuilder.AppendFormat("{0}. ***[{1}]({2})*** - **{3}**, Luck: *{4}%*, Workers: *{5}*\n", ++i, pool.Name, pool.URL, BuildHashrateString(pool.Hashrate), pool.Luck.ToString("0.#", CultureInfo.InvariantCulture), pool.WorkersCount); } builder.AddField("Top Pools", poolListBuilder.ToString(), inline: false); builder.AddField("Important note", "Everyone joining the same pool does this coin no good. To better support this project (and lambos <:emoji_51:808859069779279883>), please consider NOT joining the top pool.\n" + "By spreading across numerous pools, you support decentralization - this will make the coin be worth much more! <:emoji_54:808859529071820820>", inline: false); builder.AddField("Need more info?", $"For more information about mining pools, as well as non-top mining pools, check out [PoolMiningStats Website]({this._poolStatsOptions.WebsiteURL})!", inline: false); return(builder.Build()); }
public async Task <MiningPoolStatsData> GetPoolsDataAsync(CancellationToken cancellationToken = default) { await this._poolsLock.WaitAsync(cancellationToken).ConfigureAwait(false); try { // attempt to get cached first to avoid hammering APIs if (_cachedPoolStatsData != null && DateTime.UtcNow < this._poolStatsDataCacheTimeUTC + this._cachingOptions.CurrentValue.MiningPoolStatsDataCacheLifetime) { this._log.LogTrace("Found valid cached pools data, skipping APIs request"); return(_cachedPoolStatsData); } this._log.LogInformation("Downloading all pools data"); this._cachedPoolStatsData = await _poolStatsClient.GetDataAsync(cancellationToken).ConfigureAwait(false); this._poolStatsDataCacheTimeUTC = DateTime.UtcNow; return(this._cachedPoolStatsData); } finally { try { this._poolsLock.Release(); } catch { } } }