internal static void PreCheck(TransactionID transactionId, TransactionResponse response)
        {
            if (response.NodeTransactionPrecheckCode == Proto.ResponseCodeEnum.Ok)
            {
                return;
            }
            var responseCode = (ResponseCode)response.NodeTransactionPrecheckCode;

            throw new PrecheckException($"Transaction Failed Pre-Check: {responseCode}", transactionId.ToTxId(), responseCode, response.Cost);
        }
Beispiel #2
0
        /// <summary>
        /// Retreives all known receipts from the network having the given
        /// transaction ID.  The method will wait for the disposition of at
        /// least one receipt to be known.  Receipts with failure codes do
        /// not cause an exception to be raised.
        /// </summary>
        /// <param name="transaction">
        /// Transaction identifier of the receipt.
        /// </param>
        /// <param name="configure">
        /// Optional callback method providing an opportunity to modify
        /// the execution configuration for just this method call.
        /// It is executed prior to submitting the request to the network.
        /// </param>
        /// <returns>
        /// A list of receipts having the identified transaction.  The list
        /// may be empty or contain multiple entries.
        /// </returns>
        /// <exception cref="ConsensusException">if the receipt is known to exist but has not reached consensus
        /// within the alloted time to wait for a return from this method or the network has been too busy to
        /// respond.</exception>
        public async Task <ReadOnlyCollection <TransactionReceipt> > GetAllReceiptsAsync(TxId transaction, Action <IContext>?configure = null)
        {
            transaction             = RequireInputParameter.Transaction(transaction);
            await using var context = CreateChildContext(configure);
            var transactionId = new TransactionID(transaction);
            var query         = new Query
            {
                TransactionGetReceipt = new TransactionGetReceiptQuery
                {
                    TransactionID     = transactionId,
                    IncludeDuplicates = true
                }
            };
            var response = await Transactions.ExecuteNetworkRequestWithRetryAsync(context, query, query.InstantiateNetworkRequestMethod, shouldRetry);

            var responseCode = response.TransactionGetReceipt.Header.NodeTransactionPrecheckCode;

            if (responseCode == ResponseCodeEnum.Busy)
            {
                throw new ConsensusException("Network failed to respond to request for a transaction receipt, it is too busy. It is possible the network may still reach concensus for this transaction.", transactionId.ToTxId(), (ResponseCode)responseCode);
            }
            return(response.TransactionGetReceipt.DuplicateTransactionReceipts.ToTransactionReceiptList(response.TransactionGetReceipt.Receipt, transactionId));