예제 #1
0
        public async Task UpdateBroadcasts()
        {
            var list = await _broadcastInProgressRepository.GetAllAsync();

            foreach (var item in list)
            {
                var tx = await _dashInsightClient.GetTx(item.Hash);

                if (tx != null && tx.Confirmations >= _minConfirmations)
                {
                    _log.WriteInfo(nameof(UpdateBroadcasts),
                                   new { item.OperationId, amount = tx.GetAmount(), tx.Fees, tx.BlockHeight },
                                   $"Brodcast update is detected");

                    await _broadcastRepository.SaveAsCompletedAsync(item.OperationId, tx.GetAmount(),
                                                                    tx.Fees, tx.BlockHeight);

                    _chaosKitty.Meow(item.OperationId);

                    await _broadcastInProgressRepository.DeleteAsync(item.OperationId);

                    _chaosKitty.Meow(item.OperationId);

                    await RefreshBalances(tx);
                }
            }
        }
        public async Task BroadcastAsync(Transaction transaction, Guid operationId)
        {
            var hash = transaction.GetHash().ToString();
            var tx   = await _dashInsightClient.GetTx(hash);

            if (tx == null)
            {
                await _dashInsightClient.BroadcastTxAsync(transaction.ToHex());
            }
            else
            {
                _log.Info("Transaction already in block chain", new { transaction, operationId });
            }

            var block = await _dashInsightClient.GetLatestBlockHeight();

            await _broadcastRepository.AddAsync(operationId, hash, block);

            await _broadcastInProgressRepository.AddAsync(operationId, hash);
        }