Class MirrorNodeHttpClient

java.lang.Object
com.hedera.hashgraph.sdk.MirrorNodeHttpClient

final class MirrorNodeHttpClient extends Object
The mirror node REST adapter: the layer that owns base-URL resolution, retry, backoff and the timeout bounds, sitting between a query and an HttpTransport.

Not public API. Exporting it would make "call any mirror node REST endpoint" a supported feature forever; the decision is one-way by design, since a later release can export it and no release can unexport it.

It owns nothing. One transport can back several instances, which is what lets a single connection pool serve several mirror nodes.

This class blocks the calling thread. Queries call it from the Client's executor, matching how every other mirror node REST query in this SDK is executed.

  • Method Details

    • create

      static MirrorNodeHttpClient create(String baseUrl, HttpTransport transport, MirrorNodeHttpRetryPolicy retryPolicy, Map<String,String> requestHeaders, BooleanSupplier clientClosed)
      Build an adapter bound to one mirror node for the whole of one call.
      Parameters:
      baseUrl - the mirror node REST base URL, pinned for every attempt and every page of the call
      transport - the transport to exchange through; never closed by this class
      retryPolicy - the resolved budget, whose total deadline must already be positive
      requestHeaders - the caller headers from MirrorNodeHttpConfig
      clientClosed - whether the owning client has shut down
      Returns:
      the new adapter
    • resolveTotalDeadline

      static Duration resolveTotalDeadline(MirrorNodeHttpRetryPolicy policy, Duration clientRequestTimeout, @Nullable Duration explicitTimeout)
      Resolve the one bound that spans a whole call.

      A total deadline of zero on the policy means "inherit the client's request timeout" rather than "no bound": merged SDK policy already defines requestTimeout as the overall execution duration of a query including retries, backoff and node rotation, and a mirror node REST query is a query. An explicit per-call timeout argument overrides both.

      Parameters:
      policy - the resolved retry policy
      clientRequestTimeout - the client's request timeout
      explicitTimeout - the timeout the caller passed to execute, or null
      Returns:
      the budget for the whole call
    • getBaseUrl

      String getBaseUrl()
      Extract the mirror node this adapter is pinned to.
      Returns:
      the base URL
    • getRetryPolicy

      MirrorNodeHttpRetryPolicy getRetryPolicy()
      Extract the resolved retry budget.
      Returns:
      the policy
    • get

      Perform a GET, retrying per the policy.
      Parameters:
      path - the path below the base URL
      cancellation - the caller's cancellation, passed through unwrapped to every attempt
      deadline - the call's remaining budget tracker
      Returns:
      the response on any status the policy does not retry, including 4xx
    • post

      HttpResponse post(MirrorNodeRestPath path, String contentType, byte[] body, Cancellation cancellation, MirrorNodeHttpClient.CallDeadline deadline)
      Perform a POST, retrying per the policy.

      A POST is retried like a GET: every mirror node REST endpoint in scope is read-only, so the method is not a reason to suppress a retry. The body is replayed byte for byte on each attempt.

      Parameters:
      path - the path below the base URL
      contentType - the body's media type
      body - the request body
      cancellation - the caller's cancellation, passed through unwrapped to every attempt
      deadline - the call's remaining budget tracker
      Returns:
      the response on any status the policy does not retry, including 4xx