Skip to content

Commit

Permalink
save pre-processed data
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchyn committed Mar 18, 2024
1 parent 1ad4ecd commit 0d5358e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions snapshotter/stake.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const dbParams = {
};
const tableName = options.table;
const columnName = options.column;
const jsonPath = options.json;
let jsonPath = options.json;

const NearConfig = {
networkId: "mainnet",
Expand Down Expand Up @@ -282,7 +282,6 @@ async function checkAndFixGaps(delegators, client) {
return result;
}

let initialDelegators = {};
if (jsonPath === undefined) {
// Load pools from the chain
const blockInfo = await _near.nearArchivalConnection.provider.block({ blockId });
Expand All @@ -295,14 +294,13 @@ if (jsonPath === undefined) {
if (errors.length > 0) {
console.log("Errors", errors);
}

initialDelegators = results;
} else {
// Read the JSON file and extract the names
const data = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
initialDelegators = data;
fs.writeFileSync(`stakes_${blockId}.json`, JSON.stringify({ ...results }));
jsonPath = `stakes_${blockId}.json`;
}

const initialDelegators = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));


const client = new Client(dbParams);
await client.connect();

Expand Down

0 comments on commit 0d5358e

Please sign in to comment.