SHA256
Новый формат блоков CORE/CONTENT test5595
This commit is contained in:
@@ -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`, {
|
||||
|
||||
Reference in New Issue
Block a user