getBlock method

Future<GetBlockResponse> getBlock({
  1. required ValueHolder blockAddress,
  2. required String name,
  3. ValueHolder? digestTipAddress,
})

Returns a block object at a specified address in a journal. Also returns a proof of the specified block for verification if DigestTipAddress is provided.

For information about the data contents in a block, see Journal contents in the Amazon QLDB Developer Guide.

If the specified ledger doesn't exist or is in DELETING status, then throws ResourceNotFoundException.

If the specified ledger is in CREATING status, then throws ResourcePreconditionNotMetException.

If no block exists with the specified address, then throws InvalidParameterException.

May throw InvalidParameterException. May throw ResourceNotFoundException. May throw ResourcePreconditionNotMetException.

Parameter blockAddress : The location of the block that you want to request. An address is an Amazon Ion structure that has two fields: strandId and sequenceNo.

For example: {strandId:"BlFTjlSXze9BIh1KOszcE3",sequenceNo:14}

Parameter name : The name of the ledger.

Parameter digestTipAddress : The latest block location covered by the digest for which to request a proof. An address is an Amazon Ion structure that has two fields: strandId and sequenceNo.

For example: {strandId:"BlFTjlSXze9BIh1KOszcE3",sequenceNo:49}

Implementation

Future<GetBlockResponse> getBlock({
  required ValueHolder blockAddress,
  required String name,
  ValueHolder? digestTipAddress,
}) async {
  ArgumentError.checkNotNull(blockAddress, 'blockAddress');
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    32,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'BlockAddress': blockAddress,
    if (digestTipAddress != null) 'DigestTipAddress': digestTipAddress,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/ledgers/${Uri.encodeComponent(name)}/block',
    exceptionFnMap: _exceptionFns,
  );
  return GetBlockResponse.fromJson(response);
}