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

Commit b9efc4b

Browse files
committed
Updated logs
1 parent df9251e commit b9efc4b

File tree

12 files changed

+38
-39
lines changed

12 files changed

+38
-39
lines changed

services/blockchain-connector/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const app = Microservice({
3232
brokerTimeout: config.brokerTimeout, // in seconds
3333
logger: config.log,
3434
events: {
35-
genesisBlockIndexed: async () => {
36-
logger.debug("Received a 'genesisBlockIndexed' moleculer event from indexer.");
37-
Signals.get('genesisBlockIndexed').dispatch();
35+
'update.index.status': async payload => {
36+
logger.debug("Received a 'update.index.status' moleculer event from indexer.");
37+
Signals.get('updateIndexStatus').dispatch(payload);
3838
},
3939
},
4040
});

services/blockchain-connector/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ config.job = {
115115
config.apiClient = {
116116
heartbeatAckMaxWaitTime: Number(process.env.HEARTBEAT_ACK_MAX_WAIT_TIME) || 1000, // in millisecs
117117
aliveAssumptionTime: Number(process.env.CLIENT_ALIVE_ASSUMPTION_TIME) || 5 * 1000, // in millisecs
118+
aliveAssumptionTimeBeforeGenesis: Number(30 * 1000),
118119
instantiation: {
119120
maxWaitTime: Number(process.env.CLIENT_INSTANTIATION_MAX_WAIT_TIME) || 5 * 1000, // in millisecs
120121
retryInterval: Number(process.env.CLIENT_INSTANTIATION_RETRY_INTERVAL) || 1, // in millisecs

services/blockchain-connector/shared/sdk/client.js

+21-8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const MAX_INSTANTIATION_WAIT_TIME = config.apiClient.instantiation.maxWaitTime;
3333
const NUM_REQUEST_RETRIES = config.apiClient.request.maxRetries;
3434
const ENDPOINT_INVOKE_RETRY_DELAY = config.apiClient.request.retryDelay;
3535
const CLIENT_ALIVE_ASSUMPTION_TIME = config.apiClient.aliveAssumptionTime;
36+
const CLIENT_ALIVE_ASSUMPTION_TIME_BEFORE_GENESIS =
37+
config.apiClient.aliveAssumptionTimeBeforeGenesis;
3638
const HEARTBEAT_ACK_MAX_WAIT_TIME = config.apiClient.heartbeatAckMaxWaitTime;
3739

3840
// Caching and flags
@@ -42,6 +44,7 @@ let lastClientAliveTime;
4244
let heartbeatCheckBeginTime;
4345
let isInstantiating = false;
4446
let isClientAlive = false;
47+
let isGenesisBlockIndexed = false;
4548

4649
const pongListener = res => {
4750
isClientAlive = true;
@@ -171,19 +174,29 @@ if (config.isUseLiskIPCClient) {
171174
};
172175

173176
const genesisBlockDownloadedListener = () => {
174-
triggerRegularClientLivelinessChecks(30 * 1000);
175-
176-
// Incase genesisBlockIndexed event is not triggered by indexer wait for max 15 mins for genesis block to get indexed
177-
setTimeout(() => Signals.get('genesisBlockIndexed').dispatch(), 15 * 60 * 1000);
177+
triggerRegularClientLivelinessChecks(CLIENT_ALIVE_ASSUMPTION_TIME_BEFORE_GENESIS);
178+
logger.info(
179+
`Updated node liveliness check to occur to every ${CLIENT_ALIVE_ASSUMPTION_TIME_BEFORE_GENESIS} seconds. Will update again after checking of genesis block is indexed.`,
180+
);
178181
};
179182

180-
const genesisBlockIndexedListener = () => {
181-
clearInterval(intervalTimeout);
182-
triggerRegularClientLivelinessChecks(CLIENT_ALIVE_ASSUMPTION_TIME);
183+
const genesisBlockIndexedListener = indexStatus => {
184+
if (
185+
!isGenesisBlockIndexed &&
186+
indexStatus.data &&
187+
indexStatus.data.genesisHeight < indexStatus.data.lastIndexedBlockHeight
188+
) {
189+
clearInterval(intervalTimeout);
190+
triggerRegularClientLivelinessChecks(CLIENT_ALIVE_ASSUMPTION_TIME);
191+
isGenesisBlockIndexed = true;
192+
logger.info(
193+
`Updated node liveliness check to occur to every ${CLIENT_ALIVE_ASSUMPTION_TIME} seconds since genesis block is indexed.`,
194+
);
195+
}
183196
};
184197

185198
Signals.get('genesisBlockDownloaded').add(genesisBlockDownloadedListener);
186-
Signals.get('genesisBlockIndexed').add(genesisBlockIndexedListener);
199+
Signals.get('updateIndexStatus').add(genesisBlockIndexedListener);
187200
}
188201

189202
module.exports = {

services/blockchain-connector/shared/sdk/events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const ensureAPIClientLiveness = () => {
104104
}, config.clientConnVerifyInterval);
105105
} else {
106106
logger.info(
107-
`Cannot start the events-based client liveness check yet. Either the node is not yet synced or the genesis block hasn't been downloaded yet.\nisNodeSynced: ${isNodeSynced}, isGenesisBlockDownloaded: ${isGenesisBlockDownloaded}.`,
107+
`Cannot start the events-based client liveness check yet. Either the node is not yet synced or the genesis block hasn't been downloaded yet.\nisNodeSynced: ${isNodeSynced}, isGenesisBlockDownloaded: ${isGenesisBlockDownloaded}`,
108108
);
109109
}
110110
};

services/blockchain-indexer/events/blockchain.js

+4-15
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = [
3535
try {
3636
if (payload && Array.isArray(payload.data)) {
3737
const [block] = payload.data;
38-
logger.debug(`New block arrived (${block.id})...`);
38+
logger.debug(`Received new block (${block.id})...`);
3939
// Fork detection
4040
if (localPreviousBlockId) {
4141
if (localPreviousBlockId !== block.previousBlockId) {
@@ -68,7 +68,7 @@ module.exports = [
6868

6969
if (numberOfTransactions > 0) {
7070
logger.debug(
71-
`Block (${block.id}) arrived containing ${block.numberOfTransactions} new transactions.`,
71+
`Received block (${block.id}) containing ${block.numberOfTransactions} new transactions.`,
7272
);
7373

7474
const formattedTransactions = await formatTransactionsInBlock(block);
@@ -161,7 +161,7 @@ module.exports = [
161161
description: 'Returns true when the index is ready',
162162
controller: callback => {
163163
const indexStatusListener = async payload => {
164-
logger.debug("Dispatching 'index.ready' event over message broker.");
164+
logger.debug("Dispatching 'index.ready' event to message broker.");
165165
callback(payload);
166166
};
167167
Signals.get('blockIndexReady').add(indexStatusListener);
@@ -172,21 +172,10 @@ module.exports = [
172172
description: 'Emit index status updates.',
173173
controller: callback => {
174174
const indexStatusUpdateListener = async payload => {
175-
logger.debug("Dispatching 'update.index.status' event over message broker.");
175+
logger.debug("Dispatching 'update.index.status' event to message broker.");
176176
callback(payload);
177177
};
178178
Signals.get('updateIndexStatus').add(indexStatusUpdateListener);
179179
},
180180
},
181-
{
182-
name: 'genesisBlockIndexed',
183-
description: 'Emit event after genesis block is indexed.',
184-
controller: callback => {
185-
const genesisBlockIndexedListener = async () => {
186-
logger.debug("Dispatching 'genesisBlockIndexed' event over message broker.");
187-
callback();
188-
};
189-
Signals.get('genesisBlockIndexed').add(genesisBlockIndexedListener);
190-
},
191-
},
192181
];

services/blockchain-indexer/shared/dataService/blocks.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ const getBlocksFromServer = async params => {
4444
meta: {},
4545
};
4646

47-
if (params.blockID) logger.debug(`Retrieved block with ID ${params.blockID} from Lisk Core.`);
47+
if (params.blockID) logger.debug(`Retrieved block with ID ${params.blockID} from the node.`);
4848
else if (params.height)
49-
logger.debug(`Retrieved block with height: ${params.height} from Lisk Core.`);
50-
else logger.debug(`Retrieved block with custom search: ${util.inspect(params)} from Lisk Core.`);
49+
logger.debug(`Retrieved block with height: ${params.height} from the node.`);
50+
else logger.debug(`Retrieved block with custom search: ${util.inspect(params)} from the node.`);
5151

5252
const response = await business.getBlocks(params);
5353
if (response.data) blocks.data = response.data;

services/blockchain-indexer/shared/indexer/blockchainIndex.js

-4
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,6 @@ const indexBlock = async job => {
378378
logger.info(
379379
`Successfully indexed block ${blockToIndexFromNode.id} at height ${blockToIndexFromNode.height}.`,
380380
);
381-
382-
if (blockToIndexFromNode.height === genesisHeight) {
383-
Signals.get('genesisBlockIndexed').dispatch();
384-
}
385381
} catch (error) {
386382
// Stop genesisAsset index progress logging on errors
387383
if (blockToIndexFromNode.height === genesisHeight) {

services/export/jobs/purge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = [
2828
interval: config.job.purgeCache.interval,
2929
schedule: config.job.purgeCache.schedule,
3030
controller: () => {
31-
logger.info('Performing cache maintenance.');
31+
logger.info('Running cache maintenance.');
3232
partials.purge();
3333
staticFiles.purge();
3434
},

services/fee-estimator/shared/utils/dynamicFees.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const getEstimateFeePerByteForBatch = async (fromHeight, toHeight, cacheKey) =>
9393
await cacheRedisFees.set(cacheKey, feeEstPerByte);
9494

9595
logger.info(
96-
`Recalulated dynamic fees: L: ${feeEstPerByte.low} M: ${feeEstPerByte.med} H: ${feeEstPerByte.high}.`,
96+
`Re-calulated dynamic fees: L: ${feeEstPerByte.low} M: ${feeEstPerByte.med} H: ${feeEstPerByte.high}.`,
9797
);
9898

9999
return feeEstPerByte;

services/gateway/shared/ready.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const getReady = () => {
6060
});
6161
return { services: includeSvcForReadiness };
6262
} catch (_) {
63-
logger.error(`Current service status: ${currentSvcStatus}.`);
63+
logger.error(`Current service status:\nJSON.stringify(${currentSvcStatus}, null, '\t')`);
6464
throw new MoleculerError('Service Unavailable', 503, 'SERVICES_NOT_READY');
6565
}
6666
};

services/market/jobs/pricesUpdate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = [
2929
await updatePrices();
3030
},
3131
controller: async () => {
32-
logger.debug('Job scheduled to maintain updated market prices.');
32+
logger.debug('Job scheduled to update market prices.');
3333
await updatePrices();
3434
},
3535
},

services/transaction-statistics/shared/buildTransactionStatistics.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const insertToDB = async (statsList, date) => {
130130
await transactionStatisticsTable.deleteByPrimaryKey([id]);
131131
logger.debug(`Removed the following date from the database: ${date}.`);
132132
} catch (err) {
133-
logger.debug(`The database does not contain the entry with the following date: ${date}.`);
133+
logger.debug(`The database does not contain an entry with the following date: ${date}.`);
134134
}
135135

136136
statsList.map(statistic => {

0 commit comments

Comments
 (0)