Example #1
0
 public Task ProcessAsync(int batchSize)
 {
     return(_blockchainApiClient.EnumerateWalletBalanceBatchesAsync(
                batchSize,
                assetId => GetAssetAccuracy(assetId, batchSize),
                async batch =>
     {
         await ProcessBalancesBatchAsync(batch, batchSize);
         return true;
     }));
 }
        public async Task ProcessAsync(int batchSize)
        {
            int skip = 0;
            var balancesFromDatabase = new List <EnrolledBalance>();

            do
            {
                var received =
                    (await _enrolledBalanceRepository.GetAllForBlockchainAsync(_blockchainId, 0, 100))
                    ?.ToList();

                if (received == null || !received.Any())
                {
                    break;
                }

                balancesFromDatabase.AddRange(received);

                skip += received.Count();

                if (received.Count() < 100)
                {
                    break;
                }
            } while (true);

            var balancesFromApi = new Dictionary <(string AssetId, string Address), WalletBalance>();
            await _blockchainApiClient.EnumerateWalletBalanceBatchesAsync(
                batchSize,
                assetId => GetAssetAccuracy(assetId, batchSize),
                batch =>
            {
                if (batch != null && batch.Any())
                {
                    foreach (var item in batch)
                    {
                        balancesFromApi[(item.AssetId, item.Address.ToLower(CultureInfo.InvariantCulture))] = item;
                    }