Store safe block snapshots instead of raw blobs

This commit is contained in:
Codex Bot
2026-03-24 01:19:03 +01:00
parent 63900b8629
commit 2b0ac52e32

View File

@@ -144,6 +144,23 @@ async function indexBlock(pool: Pool, rpc: PeyaRpcClient, height: number) {
throw new Error(`Block ${height} did not return JSON`);
}
const storedBlockJson = JSON.stringify({
major_version: blockJson.major_version,
minor_version: blockJson.minor_version,
timestamp: blockJson.timestamp,
prev_id: blockJson.prev_id,
nonce: blockJson.nonce,
tx_hashes: Array.isArray(blockJson.tx_hashes) ? blockJson.tx_hashes : [],
has_aux_header: Boolean(blockJson.has_aux_header),
miner_tx: blockJson.miner_tx,
protocol_tx: blockJson.protocol_tx,
aux_header: blockJson.aux_header
? {
parent_chain: blockJson.aux_header.parent_chain ?? null
}
: null
});
const mergeMiningTagPresent = hasMergeMiningTag(blockJson.miner_tx.extra);
const hasAuxHeader = Boolean(blockJson.has_aux_header);
const isMergeMined = hasAuxHeader || mergeMiningTagPresent;
@@ -249,8 +266,8 @@ async function indexBlock(pool: Pool, rpc: PeyaRpcClient, height: number) {
mergeMiningTagPresent ? 1 : 0,
isMergeMined ? 1 : 0,
parentChainHint,
block.json,
block.blob
storedBlockJson,
""
]
);