From 091240fe3effbb600a652047ca412786129a836e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 27 Jun 2022 15:56:27 -0400 Subject: [PATCH] *Reformat --- src/rpcNetwork.ts | 2 +- src/rpcQuery.ts | 9 ++++++--- src/types.ts | 18 +++++++++--------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/rpcNetwork.ts b/src/rpcNetwork.ts index 8f537e0..fb281a2 100644 --- a/src/rpcNetwork.ts +++ b/src/rpcNetwork.ts @@ -17,7 +17,7 @@ export default class RpcNetwork { constructor(dht = new DHT()) { this._dht = dht; - this._ready = this._dht.ready() + this._ready = this._dht.ready(); } get ready(): Promise { diff --git a/src/rpcQuery.ts b/src/rpcQuery.ts index f189ea4..31e9f07 100644 --- a/src/rpcQuery.ts +++ b/src/rpcQuery.ts @@ -1,7 +1,7 @@ import { clearTimeout, setTimeout } from "timers"; import RpcNetwork from "./rpcNetwork.js"; import { pack, unpack } from "msgpackr"; -import {RPCRequest, RPCResponse} from "./types"; +import { RPCRequest, RPCResponse } from "./types"; export default class RpcQuery { private _network: RpcNetwork; @@ -42,7 +42,7 @@ export default class RpcQuery { this._promiseResolve = resolve; }); - this._timeoutTimer = + this._timeoutTimer = this._timeoutTimer ?? setTimeout( this.handeTimeout.bind(this), @@ -93,7 +93,10 @@ export default class RpcQuery { responses[responseIndex]++; } for (const responseIndex in responses) { - if (responses[responseIndex] / responseStoreKeys.length >= this._network.majorityThreshold) { + if ( + responses[responseIndex] / responseStoreKeys.length >= + this._network.majorityThreshold + ) { const response: RPCResponse | null = responseStore[responseStoreKeys[parseInt(responseIndex, 10)]]; diff --git a/src/types.ts b/src/types.ts index 86c9f6d..703c9dc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,15 +1,15 @@ export interface RPCRequest { - force: boolean; - chain: string; - query: string; - data: any; + force: boolean; + chain: string; + query: string; + data: any; } export interface RPCResponse { - updated: number; - data: - | any - | { + updated: number; + data: + | any + | { error: string | boolean; - }; + }; }