*Don't use getRpcServer directly

This commit is contained in:
Derrick Hammer 2023-01-07 23:04:36 -05:00
parent ce23f0a7b8
commit 74c20c6042
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,3 @@
import { getRpcServer } from "../modules/rpc/server";
import {
Plugin,
PluginAPI,
@ -13,6 +12,8 @@ import { get as getSwarm, LUMEWEB_TOPIC_HASH } from "../modules/swarm";
import b4a from "b4a";
import pTimeout, { ClearablePromise } from "p-timeout";
let api: PluginAPI;
async function broadcastRequest(
request: RPCRequest,
relays: string[],
@ -28,7 +29,7 @@ async function broadcastRequest(
for (const relay of relays) {
let req;
if (b4a.equals(b4a.from(relay, "hex"), getSwarm().keyPair.publicKey)) {
req = getRpcServer().handleRequest(request);
req = api.rpcServer.handleRequest(request);
} else {
req = makeRequest(relay);
}
@ -47,7 +48,8 @@ async function broadcastRequest(
const plugin: Plugin = {
name: "rpc",
async plugin(api: PluginAPI): Promise<void> {
async plugin(_api: PluginAPI): Promise<void> {
api = _api;
if (api.config.bool("cache")) {
api.registerMethod("get_cached_item", {
cacheable: false,