getBlockChain method

Future getBlockChain({
  1. required int epoch,
  2. required int limit,
})

Get the list of all the known block hashes.

Implementation

Future<dynamic> getBlockChain(
    {required int epoch, required int limit}) async {
  try {
    var response = await sendMessage(formatRequest(
            method: 'getBlockChain',
            params: {'epoch': epoch, 'limit': limit}))
        .then((Map<String, dynamic> data) {
      if (data.containsKey('error')) {
        throw NodeException.fromJson(data['error']);
      }
      if (data.containsKey('result')) {
        return data['result'];
      }
    });
    return response;
  } on NodeException catch (e) {
    throw NodeException(
        code: e.code, message: '{"getBlockChain": "${e.message}"}');
  } catch (e) {}
}