*Add a max retry limit

This commit is contained in:
Derrick Hammer 2022-08-14 09:44:32 -04:00
parent 12db0806a8
commit 2a7fa853c9
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 10 additions and 3 deletions

View File

@ -15,6 +15,8 @@ export default class RpcQuery {
private _completed: boolean = false;
private _responses: { [relay: string]: RPCResponse } = {};
private _promiseResolve?: (data: any) => void;
private _maxTries = 3;
private _tries = 0;
constructor(network: RpcNetwork, query: RPCRequest) {
this._network = network;
@ -131,12 +133,17 @@ export default class RpcQuery {
this._network.majorityThreshold
) {
// @ts-ignore
const response: RPCResponse = responseObjects[responseHash];
let response: RPCResponse | boolean = responseObjects[responseHash];
// @ts-ignore
if (null === response) {
this.retry();
return;
if (this._tries <= this._maxTries) {
this._tries++;
this.retry();
return;
}
response = false;
}
this.resolve(response);