getBlockById method
Returns a BlockResponse object for the block at the given blockId
and confidence
.
blockIdBytes
is an List of bytes representing the block ID to retrieve
blockIdString
is an String representing the block ID 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 blockID validation fails or an error occurs during the RPC request.
Implementation
Future<BlockResponse> getBlockById({
List<int> blockIdBytes = const [],
String blockIdString = "",
double? confidence,
CallOptions? options,
}) async {
if (blockIdBytes.isEmpty && blockIdString.isEmpty) {
throw Exception(ErrorMessages.missingBlockId);
}
final GetBlockByIdRequest request = GetBlockByIdRequest(
blockId: !blockIdBytes.isEmpty
? getBlockIdFromList(blockIdBytes)
: getBlockIdFromString(blockIdString),
confidenceFactor: getConfidenceFactorFromDouble(confidence),
);
final BlockResponse response = await genusBlockStub.getBlockById(
request,
options: options,
);
return response;
}