private int GetAssetAccuracy(string assetId, int batchSize) { if (!_blockchainAssets.TryGetValue(assetId, out var asset)) { // Unknown asset, tries to refresh cached assets _blockchainAssets = _blockchainApiClient .GetAllAssetsAsync(batchSize) .GetAwaiter() .GetResult(); if (!_blockchainAssets.TryGetValue(assetId, out asset)) { throw new InvalidOperationException($"Asset {assetId} not found"); } } return(asset.Accuracy); }
private async Task ProcessBalancesAsync(ITimerTrigger timer, TimerTriggeredHandlerArgs args, CancellationToken cancellationToken) { var assets = (await _assetsService.GetAllAssetsAsync(false, cancellationToken)) .Where(a => a.BlockchainIntegrationLayerId == _blockchainType) .ToDictionary( a => a.BlockchainIntegrationLayerAssetId, a => a); var blockchainAssets = await _blockchainApiClient.GetAllAssetsAsync(_batchSize); var balanceProcessor = new BalanceProcessor( _blockchainType, _logFactory, _hotWalletsProvider, _blockchainApiClient, _cqrsEngine, _enrolledBalanceRepository, assets, blockchainAssets); await balanceProcessor.ProcessAsync(_batchSize); }