From 34f200b6a5a959bd7401140b60b1af96cde6fedc Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Mon, 3 Jun 2024 22:20:21 -0700 Subject: [PATCH] Switch to readBlocks in build index --- scripts/build-raw-near-lake-index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/build-raw-near-lake-index.js b/scripts/build-raw-near-lake-index.js index 88e15a2..bbf9ccb 100644 --- a/scripts/build-raw-near-lake-index.js +++ b/scripts/build-raw-near-lake-index.js @@ -3,7 +3,7 @@ const { mkdir, writeFile, access } = require('fs/promises'); const sha256 = require('../utils/sha256'); const { writeChangesFile, readChangesFile, changeKey, mergeChangesFiles } = require('../storage/lake/changes-index'); -const { readShardBlocks } = require('../source/lake'); +const { readBlocks } = require('../source/lake'); const debug = require('debug')('build-index'); @@ -37,11 +37,10 @@ async function main() { const end = Math.min(start + BLOCKS_PER_BATCH, endBlockNumber); console.log('Processing batch', start, end); - const blocksStream = readShardBlocks({ dataDir, shard, startBlockHeight: start, endBlockHeight: end }); - const parseBlocksStream = mapStream(blocksStream, ({ data }) => JSON.parse(data.toString('utf-8'))); + const blocksStream = readBlocks({ dataDir, shards: [shard], startBlockHeight: start, endBlockHeight: end }); let changesByAccountList = []; - for await (const { chunk, state_changes } of parseBlocksStream) { + for await (const { shards: [{ chunk, state_changes }] } of blocksStream) { if (!chunk) { continue; }