public Task SendGasPriceAsync(GasPriceTypes types) => _notifier.NotifyAsync(new Notification("gas_price", new { safeLow = new { price = types.SafeLow.Price, waitTime = types.SafeLow.WaitTime }, average = new { price = types.Average.Price, waitTime = types.Average.WaitTime }, fast = new { price = types.Fast.Price, waitTime = types.Fast.WaitTime }, fastest = new { price = types.Fastest.Price, waitTime = types.Fastest.WaitTime }, custom = new { price = types.Custom.Price, waitTime = types.Custom.WaitTime }, type = types.Type, updatedAt = types.UpdatedAt }));
public async Task UpdateAsync() { var config = await _configManager.GetAsync(_configId); var result = await _client.GetAsync <Result>(Url); if (result is null) { if (_logger.IsWarn) { _logger.Warn($"There was an error when fetching the data from ETH Gas Station - using the latest gas price: {config.GasPrice} wei, type: {config.GasPriceType} as {CustomType}."); } Types = new GasPriceTypes(GasPriceDetails.Empty, GasPriceDetails.Empty, GasPriceDetails.Empty, GasPriceDetails.Empty, new GasPriceDetails(config.GasPrice, 0), CustomType, _timestamper.EpochSeconds); return; } var type = config.GasPriceType; var custom = type.Equals("custom", StringComparison.InvariantCultureIgnoreCase) ? new GasPriceDetails(config.GasPrice, 0) : GasPriceDetails.Empty; _updatedAt = _timestamper.EpochSeconds; Types = new GasPriceTypes(new GasPriceDetails(((int)result.SafeLow).GWei(), result.SafeLowWait), new GasPriceDetails(((int)result.Average).GWei(), result.AvgWait), new GasPriceDetails(((int)result.Fast).GWei(), result.FastWait), new GasPriceDetails(((int)result.Fastest).GWei(), result.FastestWait), custom, type, _updatedAt); if (_logger.IsInfo) { _logger.Info($"Updated gas price, safeLow: {Types.SafeLow.Price} wei, average: {Types.Average.Price} wei, fast: {Types.Fast.Price} wei, , fastest: {Types.Fastest.Price} wei, updated at: {_updatedAt}."); } }
public GasPriceTypesForRpc(GasPriceTypes types) { SafeLow = new GasPriceDetailsForRpc(types.SafeLow); Average = new GasPriceDetailsForRpc(types.Average); Fast = new GasPriceDetailsForRpc(types.Fast); Fastest = new GasPriceDetailsForRpc(types.Fastest); Custom = new GasPriceDetailsForRpc(types.Custom); Type = types.Type; UpdatedAt = types.UpdatedAt; }