From b5b7a0e43e99e1a9e5f1be659297be66fabc1279 Mon Sep 17 00:00:00 2001 From: Mad Wiki Date: Wed, 12 Oct 2022 17:46:09 +0800 Subject: [PATCH] getLatestCommitmentBlockNumber after checkAnchorIsWitnessMode --- src/app.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app.ts b/src/app.ts index 5627e94..eb1b53e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -178,12 +178,14 @@ async function syncBlock(appchain: ApiPromise, nextHeight: number) { await storeCommitment(header.number.toNumber(), commitment); } }); + const apiAt = await appchain.at(nextBlockHash); const events = await apiAt.query.system.events(); const containsNewSession = events.findIndex(({ event: { section, method } }) => section === "session" && method === "NewSession") > -1; if (containsNewSession) { await storeSession(nextHeight); } + let signedCommitmentHex: any; if (justificationsHuman) { (justificationsHuman as string[]).forEach(justificationHuman => { @@ -246,7 +248,9 @@ async function handleSignedCommitment( ) { const decodedSignedCommitment = decodeSignedCommitment(signedCommitmentHex); const isWitnessMode = await checkAnchorIsWitnessMode(); - + if (isWitnessMode) { + return; + } const blockNumberInAnchor = Number(await getLatestCommitmentBlockNumber()); const { blockNumber } = decodedSignedCommitment.commitment; @@ -270,7 +274,7 @@ async function handleSignedCommitment( )).toJSON(); const isAuthoritiesEqual = isEqual(currentAuthorities, previousAuthorities) - if (isWitnessMode || (unMarkedCommitments.length === 0 && (!isNewSession))) { + if (unMarkedCommitments.length === 0 && (!isNewSession)) { return; }