async function getAllEncodedBlocks()

in middleware/controllers/explorer.js [120:147]


async function getAllEncodedBlocks(req, res) {
    try {
      logger.info(`Fetching ALL blocks from cache for full graph rendering`);
  
      const cacheData = await getDataFromCache(null, null); // No start/end
  
      if (!cacheData || cacheData.length === 0) {
        logger.warn('No cache data available for full graph');
        return res.status(404).send({ error: 'No cached block data available' });
      }
  
      const modifiedData = cacheData.map(record => ({
        epoch: parseTimeToUnixEpoch(record.created_at),
        volume: record.volume || 0,
      }));
  
      const encoded = applyDeltaEncoding(modifiedData);
  
      return res.send(encoded);
  
    } catch (error) {
      logger.error('Error fetching full block data:', error);
      return res.status(500).send({
        error: 'Failed to fetch full block data',
        details: error.message,
      });
    }
  }