getBlockByDepth method

Future<BlockResponse> getBlockByDepth({
  1. int? depth,
  2. double? confidence,
  3. CallOptions? options,
})

Returns a BlockResponse object for the block at the given depth and confidence.

depth is an int representing the block depth to retrieve

confidence is a double representing the confidence factor of the block to retrieve.

options is a CallOptions object that can be used to set additional options for the RPC request.

Throws an Exception if an error occurs during the RPC request.

Implementation

Future<BlockResponse> getBlockByDepth({
  int? depth,
  double? confidence,
  CallOptions? options,
}) async {
  final ChainDistance? chainDistance = depth == null
      ? null
      : ChainDistance(
    value: Int64(depth),
  );

  final GetBlockByDepthRequest request = GetBlockByDepthRequest(
    depth: chainDistance,
    confidenceFactor: getConfidenceFactorFromDouble(confidence),
  );
  final BlockResponse response = await genusBlockStub.getBlockByDepth(
    request,
    options: options,
  );
  return response;
}