Skip to content

Commit

Permalink
Catch error with dictionary validation, this can happen if the dictio…
Browse files Browse the repository at this point in the history
…nary returns invalid metadata
  • Loading branch information
stwiname committed Oct 16, 2023
1 parent 5ff2c43 commit db75e5d
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions packages/node-core/src/indexer/dictionary.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,22 +427,27 @@ export class DictionaryService {

private dictionaryValidation(metaData?: MetaData, startBlockHeight?: number): boolean {
const validate = (): boolean => {
if (!metaData) {
return false;
}
// Some dictionaries rely on chain others rely on genesisHash
if (!this.validateChainMeta(metaData)) {
logger.error(
'The dictionary that you have specified does not match the chain you are indexing, it will be ignored. Please update your project manifest to reference the correct dictionary'
);
return false;
}
try {
if (!metaData) {
return false;
}
// Some dictionaries rely on chain others rely on genesisHash
if (!this.validateChainMeta(metaData)) {
logger.error(
'The dictionary that you have specified does not match the chain you are indexing, it will be ignored. Please update your project manifest to reference the correct dictionary'
);
return false;
}

if (startBlockHeight !== undefined && metaData.lastProcessedHeight < startBlockHeight) {
logger.warn(`Dictionary indexed block is behind current indexing block height`);
if (startBlockHeight !== undefined && metaData.lastProcessedHeight < startBlockHeight) {
logger.warn(`Dictionary indexed block is behind current indexing block height`);
return false;
}
return true;
} catch (e: any) {
logger.error(e, 'Unable to validate dictionary metadata');
return false;
}
return true;
};

const valid = validate();
Expand Down

0 comments on commit db75e5d

Please sign in to comment.