From 74c20c60425feb7f99499dfd68da80f60ce73e4d Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 7 Jan 2023 23:04:36 -0500 Subject: [PATCH] *Don't use getRpcServer directly --- src/plugins/rpc.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/rpc.ts b/src/plugins/rpc.ts index a903df1..ed506a6 100644 --- a/src/plugins/rpc.ts +++ b/src/plugins/rpc.ts @@ -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 { + async plugin(_api: PluginAPI): Promise { + api = _api; if (api.config.bool("cache")) { api.registerMethod("get_cached_item", { cacheable: false,