Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
🐛 Fix indexTokenBalances
Browse files Browse the repository at this point in the history
  • Loading branch information
sameersubudhi committed Oct 28, 2023
1 parent 571cbe6 commit 1c9e108
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions services/blockchain-indexer/shared/indexer/genesisBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ const {
MySQL: { getTableInstance },
},
Signals,
Logger,
} = require('lisk-service-framework');

const { MODULE, MODULE_SUB_STORE, getGenesisHeight } = require('../constants');
const { updateTotalStake, updateTotalSelfStake } = require('./transactionProcessor/pos/stake');
const { requestConnector } = require('../utils/request');
const { accountBalanceIndexQueue } = require('./accountBalanceIndex');
const { updateAccountBalances } = require('./accountBalanceIndex');
const { updateTotalLockedAmounts } = require('./utils/blockchainIndex');

const requestAll = require('../utils/requestAll');
const config = require('../../config');
const commissionsTableSchema = require('../database/schema/commissions');
const { getIndexStats } = require('./indexStatus');

const logger = Logger();

const MYSQL_ENDPOINT = config.endpoints.mysql;

const getCommissionsTable = () => getTableInstance(commissionsTableSchema, MYSQL_ENDPOINT);
Expand Down Expand Up @@ -144,7 +147,16 @@ const indexGenesisBlockAssets = async dbTrx => {
};

const indexTokenBalances = async () => {
allAccountsAddresses.forEach(async address => accountBalanceIndexQueue.add({ address }));
// eslint-disable-next-line no-restricted-syntax
for (const address of allAccountsAddresses) {
await updateAccountBalances(address).catch(err => {
const errorMessage = `Updating account balance for ${address} failed. Retrying.\nError: ${err.message}.`;
logger.warn(errorMessage);
logger.debug(err.stack);

allAccountsAddresses.push(address);
});
}
isTokensBalanceIndexed = true;
};

Expand Down

0 comments on commit 1c9e108

Please sign in to comment.