Пример #1
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)
    {
        await using var context = CreateChildContext(configure);
        var transactionId = new TransactionID(transaction);
        var query         = new TransactionGetReceiptQuery(transactionId, true, true) as INetworkQuery;
        var response      = await context.ExecuteNetworkRequestWithRetryAsync(query.CreateEnvelope(), query.InstantiateNetworkRequestMethod, shouldRetry).ConfigureAwait(false);

        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.AsTxId(), (ResponseCode)responseCode);
        }
        return(TransactionReceiptExtensions.Create(transactionId, response.TransactionGetReceipt.Receipt, response.TransactionGetReceipt.ChildTransactionReceipts, response.TransactionGetReceipt.DuplicateTransactionReceipts));
Пример #2
0
 /// <summary>
 /// Internal Helper function used to wait for conesnsus regardless of the reported
 /// transaction outcome. We do not know if the transaction in question has come
 /// to consensus so we need to get the receipt first (and wait if necessary).
 /// The Receipt status returned does notmatter in this case.
 /// We may be retrieving a failed record (the status would not equal OK).
 private async Task WaitForConsensusReceipt(GossipContextStack context, TransactionID transactionId)
 {
     var query = new TransactionGetReceiptQuery(transactionId, false, false) as INetworkQuery;
     await context.ExecuteNetworkRequestWithRetryAsync(query.CreateEnvelope(), query.InstantiateNetworkRequestMethod, shouldRetry).ConfigureAwait(false);