你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

ConfidentialLedgerClient.GetReceiptAsync(String, RequestContext) 方法

定义

[协议方法]获取证明特定事务 ID 处账本内容的收据。

  • 协议方法 允许显式创建请求并处理高级方案的响应。
public virtual System.Threading.Tasks.Task<Azure.Response> GetReceiptAsync (string transactionId, Azure.RequestContext context = default);
abstract member GetReceiptAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetReceiptAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetReceiptAsync (transactionId As String, Optional context As RequestContext = Nothing) As Task(Of Response)

参数

transactionId
String

标识写入事务。

context
RequestContext

请求上下文,可以基于每个调用替代客户端管道的默认行为。

返回

从服务返回的响应。

例外

transactionId 为 null。

transactionId 是一个空字符串,预期为非空。

服务返回了非成功状态代码。

示例

此示例演示如何使用所需的参数调用 GetReceiptAsync 并分析结果。

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ConfidentialLedgerClient(endpoint, credential);

Response response = await client.GetReceiptAsync("<transactionId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("receipt").GetProperty("cert").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("leaf").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("leafComponents").GetProperty("claimsDigest").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("leafComponents").GetProperty("commitEvidence").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("leafComponents").GetProperty("writeSetDigest").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("nodeId").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("proof")[0].GetProperty("left").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("proof")[0].GetProperty("right").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("root").ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("serviceEndorsements")[0].ToString());
Console.WriteLine(result.GetProperty("receipt").GetProperty("signature").ToString());
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("transactionId").ToString());

注解

下面是响应有效负载的 JSON 架构。

响应正文:

TransactionReceipt架构:

{
  receipt: {
    cert: string, # Optional.
    leaf: string, # Optional.
    leafComponents: {
      claimsDigest: string, # Optional.
      commitEvidence: string, # Optional.
      writeSetDigest: string, # Optional.
    }, # Optional.
    nodeId: string, # Required.
    proof: [
      {
        left: string, # Optional.
        right: string, # Optional.
      }
    ], # Required.
    root: string, # Optional.
    serviceEndorsements: [string], # Optional.
    signature: string, # Required.
  }, # Optional.
  state: "Loading" | "Ready", # Required. State of a ledger query.
  transactionId: string, # Required. A unique identifier for the state of the ledger. If returned as part of a LedgerEntry, it indicates the state from which the entry was read.
}

适用于