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