Example #1
0
        public async Task TryCheckAllTransactions()
        {
            _updatedTransactions = new HashSet <Transaction>();
            await GetKnownTransactions();
            await GetDataFromNxtServer();

            _newTransactions = _nxtTransactions.Except(_knownTransactions).ToList();
            _allTransactions = _newTransactions.Union(_knownTransactions).ToList();

            CheckDgsPurchaseTransactions();
            CheckDgsDeliveryTransactions();
            await UpdateNewMsReserveIncreaseTransactions();
            await UpdateNewMsReserveClaimTransactions();
            await UpdateNewShufflingRegistrationTransactions();

            if (!BalancesMatch())
            {
                await GetNewAssetTrades();

                await _assetTracker.UpdateAssetOwnership(_newTransactions);
                await CheckMsExchanges();
            }

            await CheckSentDividendTransactions();
            await CheckExpiredExchangeOffers();

            if (!BalancesMatch())
            {
                await CheckReceivedDividendTransactions();

                var forgeTransactions = await _nxtServer.GetForgingIncomeAsync(_lastBalanceMatchBlock.Timestamp);

                _newTransactions.AddRange(forgeTransactions);
                await CheckExpiredDgsPurchases();
                await CheckMsUndoCrowdfundingTransaction();
                await CheckFinishedShufflingTransactions();
                await CheckShufflingDistributionTransactions();

                var deletedTransactions = await RemovePreviouslyUnconfirmedNowRemovedTransactions();

                if (BalancesMatch(deletedTransactions))
                {
                    await _walletRepository.UpdateLastBalanceMatchBlockIdAsync(_blockchainStatus.LastBlockId);
                }
            }
            else
            {
                await _walletRepository.UpdateLastBalanceMatchBlockIdAsync(_blockchainStatus.LastBlockId);
            }

            GetTransactionsWithUpdatedConfirmation()
            .Union(await HandleNewTransactions())
            .ToList()
            .ForEach(t => _updatedTransactions.Add(t));
            await HandleUpdatedTransactions();
            await HandleBalance();

            await _assetTracker.SaveOwnerships();
        }