*Consolidate all dns setup into 1 function and store the promise
*await on the dns setup promise on the cached resolve function
This commit is contained in:
parent
1ef168cd9e
commit
3f8e7075a1
|
@ -10,6 +10,7 @@ import {
|
|||
ResolverOptions,
|
||||
} from "@lumeweb/libresolver";
|
||||
import { blake2b, bufToHex, Err } from "libskynet/dist";
|
||||
import { getDnsSetupPromise } from "./main/vars.js";
|
||||
|
||||
const cache = new NodeCache({ stdTTL: 60 });
|
||||
|
||||
|
@ -27,7 +28,7 @@ export async function resolve(
|
|||
return cache.get(cacheId) as DNSResult;
|
||||
}
|
||||
|
||||
await dnsReady();
|
||||
await getDnsSetupPromise();
|
||||
|
||||
let res;
|
||||
try {
|
||||
|
|
|
@ -216,11 +216,10 @@ async function boot() {
|
|||
document.body.appendChild(getKernelIframe());
|
||||
|
||||
setupContextMenus(engine);
|
||||
await registerResolvers();
|
||||
await dnsReady();
|
||||
setDnsSetupPromise(dnsSetup());
|
||||
}
|
||||
|
||||
async function registerResolvers() {
|
||||
async function dnsSetup() {
|
||||
const resolvers = [
|
||||
"AQBXtVkPDbZ5Qmjl8dzJ0siSYaFcS3XbDZHapxmZCLfwfg", // icann
|
||||
"AQAI3TbarrXRxWtrb_5XO-gMYg-UsjVAChue5JEoqywbAw", // eip137
|
||||
|
@ -234,6 +233,8 @@ async function registerResolvers() {
|
|||
for (const resolver of resolvers) {
|
||||
await callModule(resolver, "register");
|
||||
}
|
||||
|
||||
await dnsReady();
|
||||
}
|
||||
|
||||
boot();
|
||||
|
|
|
@ -17,6 +17,7 @@ let blockForBridge = new Promise((resolve) => {
|
|||
bridgeLoadedResolve = resolve;
|
||||
});
|
||||
let kernelFrame: HTMLIFrameElement;
|
||||
let blockForDnsSetup: Promise<void>;
|
||||
|
||||
export function getAuthStatusKnown() {
|
||||
return authStatusKnown;
|
||||
|
@ -94,6 +95,12 @@ export function setKernelIframe(iframe: HTMLIFrameElement) {
|
|||
kernelFrame = iframe;
|
||||
}
|
||||
|
||||
export function setDnsSetupPromise(p: Promise<void>) {
|
||||
blockForDnsSetup = p;
|
||||
}
|
||||
export function getDnsSetupPromise(): Promise<void> {
|
||||
return blockForDnsSetup;
|
||||
}
|
||||
export function getAuthStatusResolve(): DataFn {
|
||||
return authStatusResolve;
|
||||
}
|
||||
|
|
Reference in New Issue