getBlockTransactionCountByNumber method

Future<int> getBlockTransactionCountByNumber (MoacDefaultBlock blockNumber)

Block Transaction Count By Number The number of transactions in a block matching the given block number. If the method returns null a count of 0 is returned, this is to distinguish between this and an error.

Implementation

Future<int> getBlockTransactionCountByNumber(
    MoacDefaultBlock blockNumber) async {
  if (blockNumber == null) {
    throw ArgumentError.notNull(
        "Moac::getBlockTransactionCountByNumber - blockNumber");
  }
  final String method = MoacRpcMethods.blockTransactionCountByNumber;
  final String blockString = blockNumber.getSelection();
  final List params = [blockString];
  final res = await rpcClient.request(method, params);
  if (res != null && res.containsKey(moacResultKey)) {
    if (res[moacResultKey] != null) {
      return MoacUtilities.hexToInt(res[moacResultKey]);
    } else {
      return 0;
    }
  }
  _processError(method, res);
  return null;
}