UNPKG

@kyve/core-beta

Version:

🚀 The base KYVE node implementation.

32 lines (31 loc) • 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.saveBundleDecompress = void 0; const utils_1 = require("../../utils"); /** * saveBundleDecompress decompresses a bundle with the specified compression. * It never throws an error and returns no data if one occurs. * * @method saveBundleDecompress * @param {Node} this * @param {Buffer} rawStorageData * @return {Promise<DataItem[]>} */ async function saveBundleDecompress(rawStorageData) { var _a, _b, _c, _d; try { // get compression the proposed bundle was compressed with this.logger.debug(`compressionFactory(${(_b = (_a = this.pool.bundle_proposal) === null || _a === void 0 ? void 0 : _a.compression_id) !== null && _b !== void 0 ? _b : 0})`); const compression = this.compressionFactory((_d = (_c = this.pool.bundle_proposal) === null || _c === void 0 ? void 0 : _c.compression_id) !== null && _d !== void 0 ? _d : 0); this.logger.debug(`this.compression.decompress($RAW_STORAGE_DATA)`); const storageBundle = (0, utils_1.bytesToBundle)(await compression.decompress(rawStorageData)); this.logger.info(`Successfully decompressed bundle with Compression:${compression.name}`); return (0, utils_1.standardizeJSON)(storageBundle); } catch (err) { this.logger.error(`Could not decompress bundle with Compression. Continuing ...`); this.logger.error((0, utils_1.standardizeJSON)(err)); return []; } } exports.saveBundleDecompress = saveBundleDecompress;