*Don't use getRpcServer directly
This commit is contained in:
parent
ce23f0a7b8
commit
74c20c6042
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue