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,