*prettier
This commit is contained in:
parent
9071ed0592
commit
f76391d46e
12
src/index.ts
12
src/index.ts
|
@ -4,19 +4,18 @@ import {Buffer} from "buffer";
|
|||
|
||||
const DHT_MODULE = "AQD1IgE4lTZkq1fqdoYGojKRNrSk0YQ_wrHbRtIiHDrnow";
|
||||
|
||||
let callModule: any,
|
||||
connectModule: any;
|
||||
let callModule: any, connectModule: any;
|
||||
|
||||
async function loadLibs() {
|
||||
if (callModule && connectModule) {
|
||||
return;
|
||||
}
|
||||
if (typeof window !== "undefined" && window?.document) {
|
||||
const pkg = (await import("libkernel"));
|
||||
const pkg = await import("libkernel");
|
||||
callModule = pkg.callModule;
|
||||
connectModule = pkg.connectModule;
|
||||
} else {
|
||||
const pkg = (await import("libkmodule"));
|
||||
const pkg = await import("libkmodule");
|
||||
callModule = pkg.callModule;
|
||||
connectModule = pkg.connectModule;
|
||||
}
|
||||
|
@ -57,7 +56,10 @@ export class DHT {
|
|||
public async removeRelay(pubkey: string): Promise<void> {
|
||||
await loadLibs();
|
||||
const dht = !this.useDefaultDht ? this.id : undefined;
|
||||
const [, err] = await callModule(DHT_MODULE, "removeRelay", {pubkey, dht});
|
||||
const [, err] = await callModule(DHT_MODULE, "removeRelay", {
|
||||
pubkey,
|
||||
dht,
|
||||
});
|
||||
if (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue