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