*Add a max retry limit
This commit is contained in:
parent
12db0806a8
commit
2a7fa853c9
|
@ -15,6 +15,8 @@ export default class RpcQuery {
|
||||||
private _completed: boolean = false;
|
private _completed: boolean = false;
|
||||||
private _responses: { [relay: string]: RPCResponse } = {};
|
private _responses: { [relay: string]: RPCResponse } = {};
|
||||||
private _promiseResolve?: (data: any) => void;
|
private _promiseResolve?: (data: any) => void;
|
||||||
|
private _maxTries = 3;
|
||||||
|
private _tries = 0;
|
||||||
|
|
||||||
constructor(network: RpcNetwork, query: RPCRequest) {
|
constructor(network: RpcNetwork, query: RPCRequest) {
|
||||||
this._network = network;
|
this._network = network;
|
||||||
|
@ -131,14 +133,19 @@ export default class RpcQuery {
|
||||||
this._network.majorityThreshold
|
this._network.majorityThreshold
|
||||||
) {
|
) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const response: RPCResponse = responseObjects[responseHash];
|
let response: RPCResponse | boolean = responseObjects[responseHash];
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (null === response) {
|
if (null === response) {
|
||||||
|
if (this._tries <= this._maxTries) {
|
||||||
|
this._tries++;
|
||||||
this.retry();
|
this.retry();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response = false;
|
||||||
|
}
|
||||||
|
|
||||||
this.resolve(response);
|
this.resolve(response);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue