Новый формат блоков CORE/CONTENT test5595

This commit is contained in:
AidarKC
2026-11-27 10:04:22 +03:00
parent d3a84dd451
commit f9e7c4ef94
180 changed files with 15365 additions and 1301 deletions
@@ -1,3 +1,4 @@
import { unpackCoreContent } from './core-content.js';
import { t } from '../i18n/index.js';
const SNAPSHOT_STORAGE_KEY = 'shine-ui-blockchain-snapshot-v1';
@@ -77,8 +78,10 @@ export async function buildBlockchainSnapshotFile({
throw new Error(t('remaining.blockchain_snapshot.no_blocks_available_on_the_server_for_a_snapshot'));
}
const parts = [];
let totalBytes = 0;
// Snapshot v2: magic followed by u32 BE container length + original container.
const magic = new TextEncoder().encode('SHINECC2');
const parts = [magic];
let totalBytes = magic.length;
for (let blockNumber = 0; blockNumber <= maxBlockNumber; blockNumber += 1) {
const response = await authService.ws.request('GetBlockchainBlock', {
blockchainName: cleanBlockchainName,
@@ -89,8 +92,11 @@ export async function buildBlockchainSnapshotFile({
throw new Error(`Не удалось скачать блок ${blockNumber}: ${message}`);
}
const blockBytes = decodeBase64ToBytes(response?.payload?.blockBytesB64 || '');
parts.push(blockBytes);
totalBytes += blockBytes.length;
unpackCoreContent(blockBytes);
const length = new Uint8Array(4);
new DataView(length.buffer).setUint32(0, blockBytes.length);
parts.push(length, blockBytes);
totalBytes += 4 + blockBytes.length;
}
const file = new File(parts, `${cleanBlockchainName}.shine-blockchain`, {