Example #1
0
        /// <inheritdoc/>
        public async Task <TransactionResult> GetResultAsync(Hash txId)
        {
            // in storage
            var res = await _transactionResultManager.GetTransactionResultAsync(txId);

            if (res != null)
            {
                return(res);
            }

            // in tx pool
            if (_txHub.TryGetTx(txId, out var tx))
            {
                return(new TransactionResult
                {
                    TransactionId = tx.GetHash(),
                    Status = Status.Pending
                });
            }

            // not existed
            return(new TransactionResult
            {
                TransactionId = txId,
                Status = Status.NotExisted
            });
        }
Example #2
0
        /// <inheritdoc/>
        public async Task <TransactionResult> GetResultAsync(Hash txId)
        {
            /*// found in cache
             * if (_cacheResults.TryGetValue(txId, out var res))
             * {
             *  return res;
             * }*/


            // in storage
            var res = await _transactionResultManager.GetTransactionResultAsync(txId);

            if (res != null)
            {
                _cacheResults[txId] = res;
                return(res);
            }

            // in tx pool
            if (_txHub.TryGetTx(txId, out var tx))
            {
                return(new TransactionResult
                {
                    TransactionId = tx.GetHash(),
                    Status = Status.Pending
                });
            }

            // not existed
            return(new TransactionResult
            {
                TransactionId = txId,
                Status = Status.NotExisted
            });
        }