Skip to content

Commit

Permalink
moved log into approved ref query
Browse files Browse the repository at this point in the history
And added logging of queries which are not handled
  • Loading branch information
Bullrich committed Feb 29, 2024
1 parent 31f4098 commit 0d45e7a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,27 @@ export const getAllRFCRemarks = async (
);
continue;
}
} else {
logger.debug(`Reference query is not ongoing: ${JSON.stringify(refQuery)}`);
if (refQuery.approved) {
const [approvalDate] = refQuery.approved;
const blockDate = await getBlockDate(approvalDate, api);
if (startDate > blockDate) {
logger.info(`Confirmation of referenda #${index} happened before the previous check. Ignoring.`);
continue;
}

logger.debug(`Fetching info from referenda ${index} from Subsquare`);
const rfc = await subsquareApi.fetchReferenda(index);
const confirmedBlock = rfc.onchainData.timeline.find(({ name }) => name === "Confirmed");
if (confirmedBlock) {
completed.push({
hash: rfc.onchainData.proposalHash,
executedHash: confirmedBlock.indexer.blockHash,
index,
});
}
} else if (refQuery.approved) {
logger.debug(`Referendum has been approved: ${JSON.stringify(refQuery)}`);
const [approvalDate] = refQuery.approved;
const blockDate = await getBlockDate(approvalDate, api);
if (startDate > blockDate) {
logger.info(`Confirmation of referenda #${index} happened before the previous check. Ignoring.`);
continue;
}

logger.debug(`Fetching info from referenda ${index} from Subsquare`);
const rfc = await subsquareApi.fetchReferenda(index);
const confirmedBlock = rfc.onchainData.timeline.find(({ name }) => name === "Confirmed");
if (confirmedBlock) {
completed.push({
hash: rfc.onchainData.proposalHash,
executedHash: confirmedBlock.indexer.blockHash,
index,
});
}
} else {
logger.debug(`Referendum state will not be handled ${JSON.stringify(refQuery)}`);
}
}

Expand Down

0 comments on commit 0d45e7a

Please sign in to comment.