*Only try to stringify the data if it is not already a string
This commit is contained in:
parent
9393ffc4c1
commit
7dff9a1ab4
|
@ -1,13 +1,6 @@
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
import DHTCache from "@lumeweb/dht-cache";
|
import DHTCache from "@lumeweb/dht-cache";
|
||||||
import {
|
import { RPCCacheItem, RPCRequest, RPCResponse } from "@lumeweb/relay-types";
|
||||||
RPCCacheData,
|
|
||||||
RPCCacheItem,
|
|
||||||
RPCRequest,
|
|
||||||
RPCResponse,
|
|
||||||
} from "@lumeweb/relay-types";
|
|
||||||
import { getRpcByPeer } from "../rpc";
|
|
||||||
import b4a from "b4a";
|
|
||||||
import { get as getSwarm } from "../swarm";
|
import { get as getSwarm } from "../swarm";
|
||||||
import { RPCServer } from "./server";
|
import { RPCServer } from "./server";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -50,8 +43,11 @@ export class RPCCache extends EventEmitter {
|
||||||
const field = item.value.signedField || "data";
|
const field = item.value.signedField || "data";
|
||||||
const updated = item.value.updated;
|
const updated = item.value.updated;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const data = item.value[field];
|
let json = item.value[field];
|
||||||
const json = jsonStringify(data);
|
|
||||||
|
if (typeof json !== "string") {
|
||||||
|
json = jsonStringify(json);
|
||||||
|
}
|
||||||
|
|
||||||
return this.server.signData(`${updated}${json}`);
|
return this.server.signData(`${updated}${json}`);
|
||||||
}
|
}
|
||||||
|
@ -60,8 +56,11 @@ export class RPCCache extends EventEmitter {
|
||||||
const field = item.value.signedField || "data";
|
const field = item.value.signedField || "data";
|
||||||
const updated = item.value.updated;
|
const updated = item.value.updated;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const data = item.value[field];
|
let json = item.value[field];
|
||||||
const json = jsonStringify(data);
|
|
||||||
|
if (typeof json !== "string") {
|
||||||
|
json = jsonStringify(json);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in New Issue