2022-12-04 10:39:59 +00:00
|
|
|
import { hashQuery } from "../util.js";
|
|
|
|
import SimpleRpcQuery from "./simple.js";
|
|
|
|
export default class ClearCacheRpcQuery extends SimpleRpcQuery {
|
|
|
|
_relays;
|
2023-03-18 16:11:41 +00:00
|
|
|
constructor({ network, relays, query, options, }) {
|
|
|
|
super({ network, relay: "", query, options });
|
2022-12-04 10:39:59 +00:00
|
|
|
this._relays = relays;
|
|
|
|
}
|
|
|
|
async _run() {
|
|
|
|
// @ts-ignore
|
|
|
|
this._relay = getActiveRelay().stream.remotePublicKey;
|
|
|
|
await this.queryRelay();
|
|
|
|
await this.checkResponses();
|
|
|
|
}
|
|
|
|
async queryRelay() {
|
2023-03-18 16:11:41 +00:00
|
|
|
return this.queryRpc(this._network.getAvailableRelay("rpc", "broadcast_request"), {
|
2022-12-04 10:39:59 +00:00
|
|
|
module: "rpc",
|
|
|
|
method: "broadcast_request",
|
|
|
|
data: {
|
|
|
|
request: {
|
|
|
|
module: "rpc",
|
|
|
|
method: "clear_cached_item",
|
|
|
|
data: hashQuery(this._query),
|
|
|
|
},
|
|
|
|
relays: this._relays,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|