コード例 #1
0
        private async Task ProcessWallet(string address)
        {
            try
            {
                var addressBalance = await GetAddressBalanceAsync(address);

                if (addressBalance != null && addressBalance.Balance > 0)
                {
                    var walletEntry = await _walletBalanceRepository.GetAsync(address);

                    if (walletEntry == null)
                    {
                        walletEntry = new WalletBalance
                        {
                            Address = address
                        };
                    }
                    if (walletEntry.Balance != addressBalance.Balance)
                    {
                        walletEntry.Balance = addressBalance.Balance;
                        walletEntry.Ledger  = await _horizonService.GetLedgerNoOfLastPayment(address);

                        await _walletBalanceRepository.InsertOrReplaceAsync(walletEntry);
                    }
                }
                else
                {
                    await _walletBalanceRepository.DeleteIfExistAsync(address);
                }
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(BalanceService), nameof(ProcessWallet),
                                           $"Failed to process wallet during balance update. address={address}", ex);
            }
        }