Store safe block snapshots instead of raw blobs
This commit is contained in:
@@ -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,
|
||||
""
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user