getSyncStatus method

Future<SyncInformation> getSyncStatus()

Returns an object indicating whether the node is currently synchronising with its network.

If so, progress information is returned via SyncInformation.

Implementation

Future<SyncInformation> getSyncStatus() async {
  final data = await _makeRPCCall<dynamic>('eth_syncing');

  if (data is Map) {
    final startingBlock = hexToInt(data['startingBlock'] as String).toInt();
    final currentBlock = hexToInt(data['currentBlock'] as String).toInt();
    final highestBlock = hexToInt(data['highestBlock'] as String).toInt();

    return SyncInformation(startingBlock, currentBlock, highestBlock);
  } else {
    return SyncInformation(null, null, null);
  }
}