private async Task SyncMinersAsync(string id, CancellationToken token) { try { _logger.LogInformation("Starting miner sync"); var miners = await _minerService.GetAllAsync(token); foreach (var miner in miners.Where(m => m.IsSynced != true).ToList()) { try { _logger.LogInformation($"Syncing miner {miner.Id}"); await _serverService.SyncMinerAsync(id, miner, token); await _minerService.SetSyncedAsync(miner, token); } catch (Exception ex) { _logger.LogError(ex, $"Error syncing miner {miner.Id}"); } } _logger.LogInformation("Finished miner sync"); } catch (Exception ex) { _logger.LogError(ex, "Error syncing miners"); throw; } }
public async Task <IEnumerable <Miner> > GetAsync(CancellationToken token = default) { return(await _minerService.GetAllAsync(token)); }