getBlockByHeight method

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

////////////////////////// Blocks Returns a BlockResponse object for the block at the given height and confidence.

height is an int representing the block height 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

/// Returns a [BlockResponse] object for the block at the given [height] and [confidence].
///
/// [height] is an [int] representing the block height 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.
Future<BlockResponse> getBlockByHeight({
  int? height,
  double? confidence,
  CallOptions? options,
}) async {
  final ChainDistance? chainHeight = height == null
      ? null
      : ChainDistance(
    value: Int64(height),
  );

  final GetBlockByHeightRequest request = GetBlockByHeightRequest(
    confidenceFactor: getConfidenceFactorFromDouble(confidence),
    height: chainHeight,
  );
  final BlockResponse response = await genusBlockStub.getBlockByHeight(
    request,
    options: options,
  );
  return response;
}