read method

Implementation

Future<List<TikiChainBlock>> read(List<Uint8List> hash) async {
  List<TikiChainCacheModel> cachedBlocks =
      await _cacheRepository.getAll(hash);
  List<DBModel> syncStates =
      await _syncChain.getState(cachedBlocks.map((b) => b.hash!).toList());
  Map<Uint8List, DBModel> syncMap =
      Map.fromEntries(syncStates.map((sync) => MapEntry(sync.hash!, sync)));
  return cachedBlocks
      .map((cache) =>
          TikiChainBlock.join(cache: cache, sync: syncMap[cache.hash]))
      .toList();
}