Skip to content

Commit 3ff980c

Browse files
committed
feat(explorer): only enable certificate verification cache in unstable builds
1 parent 51b3641 commit 3ff980c

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

mithril-explorer/src/components/VerifyCertificate/CertificateVerifier.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function CertificateVerifier({
5252
certificate,
5353
hideSpinner = false,
5454
showCertificateLinks = false,
55-
certificateChainVerificationCacheEnabled = true,
55+
isCacheEnabled = false,
5656
onStepChange = (step) => {},
5757
onChainValidationError = (error) => {},
5858
onCertificateClick = (hash) => {},
@@ -217,15 +217,14 @@ export default function CertificateVerifier({
217217
.map((evt) => (
218218
<div key={evt.id}>{evt.message}</div>
219219
))}
220-
{certificateChainVerificationCacheEnabled &&
221-
currentStep === certificateValidationSteps.done && (
222-
<>
223-
Cache enabled:{" "}
224-
<a href="#" onClick={onCacheResetClick}>
225-
reset cache
226-
</a>
227-
</>
228-
)}
220+
{isCacheEnabled && currentStep === certificateValidationSteps.done && (
221+
<>
222+
Cache enabled:{" "}
223+
<a href="#" onClick={onCacheResetClick}>
224+
reset cache
225+
</a>
226+
</>
227+
)}
229228
{validationError !== undefined && (
230229
<Alert variant="danger" className="mt-2">
231230
<Alert.Heading>

mithril-explorer/src/components/VerifyCertificate/VerifyCertificateModal.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function VerifyCertificateModal({ show, onClose, certificateHash
1111
const [showLoadingWarning, setShowLoadingWarning] = useState(false);
1212
const [client, setClient] = useState(undefined);
1313
const [certificate, setCertificate] = useState(undefined);
14-
const enableCertificateChainVerificationCache = true;
14+
const [isCacheEnabled, setIsCacheEnabled] = useState(false);
1515

1616
useEffect(() => {
1717
if (show) {
@@ -31,14 +31,19 @@ export default function VerifyCertificateModal({ show, onClose, certificateHash
3131

3232
async function init(aggregator, certificateHash) {
3333
const genesisVerificationKey = await fetchGenesisVerificationKey(aggregator);
34-
const client = new MithrilClient(aggregator, genesisVerificationKey, {
35-
unstable: true,
36-
enable_certificate_chain_verification_cache: enableCertificateChainVerificationCache,
37-
});
34+
const isCacheEnabled = process.env.UNSTABLE === true;
35+
const client_options = process.env.UNSTABLE
36+
? {
37+
unstable: true,
38+
enable_certificate_chain_verification_cache: isCacheEnabled,
39+
}
40+
: {};
41+
const client = new MithrilClient(aggregator, genesisVerificationKey, client_options);
3842
const certificate = await client.get_mithril_certificate(certificateHash);
3943

4044
setClient(client);
4145
setCertificate(certificate);
46+
setIsCacheEnabled(isCacheEnabled);
4247
}
4348

4449
function handleModalClose() {
@@ -73,7 +78,7 @@ export default function VerifyCertificateModal({ show, onClose, certificateHash
7378
<CertificateVerifier
7479
client={client}
7580
certificate={certificate}
76-
certificateChainVerificationCacheEnabled={enableCertificateChainVerificationCache}
81+
isCacheEnabled={isCacheEnabled}
7782
onStepChange={(step) =>
7883
setLoading(step === certificateValidationSteps.validationInProgress)
7984
}

0 commit comments

Comments
 (0)