*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,12 +133,17 @@ 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) {
|
||||||
this.retry();
|
if (this._tries <= this._maxTries) {
|
||||||
return;
|
this._tries++;
|
||||||
|
this.retry();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
response = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resolve(response);
|
this.resolve(response);
|
||||||
|
|
Loading…
Reference in New Issue